Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 以日期表示的时间?_Php_Date - Fatal编程技术网

Php 以日期表示的时间?

Php 以日期表示的时间?,php,date,Php,Date,当我有UNIX时间戳时,我会写: strftime("%A", $date) 但现在我有了邮戳,比如“2011-08-02” 如何使其输出工作日名称,例如“Sunday”?使用date('l')添加更多属性,如:date('ld-m-Y') 更多信息您可以使用函数将日期戳转换为时间戳。 一旦有了时间戳,您就可以使用该功能以所需格式显示日期。(2011年8月2日是星期二,不是星期日。) 首先使用该函数将“2011-08-02”转换为UNIX时间戳,然后按照通常的方式进行操作 例如,以

当我有UNIX时间戳时,我会写:

strftime("%A", $date)
但现在我有了邮戳,比如“2011-08-02”

如何使其输出工作日名称,例如“Sunday”?

使用
date('l')添加更多属性,如:
date('ld-m-Y')


更多信息

您可以使用函数将日期戳转换为时间戳。 一旦有了时间戳,您就可以使用该功能以所需格式显示日期。

(2011年8月2日是星期二,不是星期日。)



首先使用该函数将“2011-08-02”转换为UNIX时间戳,然后按照通常的方式进行操作

例如,以下是等效的:

$date = 1312243200; // A unix timestamp
$date = strtotime('2011-08-02'); // The date that it represents
然后你可以对结果做任何你通常会做的事情


strotime()函数接受的日期格式相当宽容,甚至可以接受诸如“明天8pm”或“上周一”之类的值,例如:date(“g:i a F j Y”,strotime(time()))//将于2011年7月20日上午10:20打印
date
vs
strftime
与问题无关。对于symmetryAgreed,最好
$date=strotime('2011-08-02')
。也使答案更加笼统。
date('l',strtotime('2011-08-02'));
$date = 1312243200; // A unix timestamp
$date = strtotime('2011-08-02'); // The date that it represents