Php 以日期表示的时间?
当我有UNIX时间戳时,我会写: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时间戳,然后按照通常的方式进行操作 例如,以
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
vsstrftime
与问题无关。对于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