找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 983|回复: 6

[iptv信源 资源分享或寻求] 请教个关于php中转换时间的问题

[复制链接]
发表于 2021-4-18 13:34 | 显示全部楼层 |阅读模式
本帖最后由 fxgsfxgs 于 2021-4-18 13:39 编辑

php中这样的时间04月11日[日],怎么转换成2021-04-11这种标准时间,或者把2021-04-11转换成04月11日[日]
我的恩山、我的无线 The best wifi forum is right here.
发表于 2021-4-18 18:53 | 显示全部楼层
date("Y年m月d日",strtotime('2021-04-11'))

点评

你这个不对吧,还有星期几没有  详情 回复 发表于 2021-4-18 18:57
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2021-4-18 18:57 | 显示全部楼层
艸牛 发表于 2021-4-18 18:53
date("Y年m月d日",strtotime('2021-04-11'))

你这个不对吧,还有星期几没有

点评

直接百度 php 时间戳转星期 一堆结果。  详情 回复 发表于 2021-4-19 08:24
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-4-19 08:24 | 显示全部楼层
fxgsfxgs 发表于 2021-4-18 18:57
你这个不对吧,还有星期几没有

直接百度 php 时间戳转星期 一堆结果。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-4-19 09:11 | 显示全部楼层
<?php
$str1="04月11日[日]";
$year="2021";  //这个得自己写,因为没给出来
preg_match("/(\d{2}).*(\d{2}).*/",$str1,$matches);
$out = $year."-".$matches[1]."-".$matches[2];
echo $out;

echo "\n\n";


$str2="2021-04-11";
$out2= date("m月d日",strtotime('2021-04-11'));
echo $out2."[日]";
?>
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2021-4-19 10:35 | 显示全部楼层

<?php
$date=date("Y-m-d");
$c=date("w",strtotime($date));
$weekArr=array("[日]","[一]","[二]","[三]","[四]","[五]","[六]");
$a=$weekArr[$c];
$b=date("m月d日",strtotime($date));
$d=$b.$a;
echo $d;
?>这样写对不对

点评

也可以。我没想到你那个“日”是星期“日”。  详情 回复 发表于 2021-4-19 11:05
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-4-19 11:05 | 显示全部楼层

也可以。我没想到你那个“日”是星期“日”。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-25 19:14

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表