php 如何从日期获取当天的数字?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10266706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 21:47:13  来源:igfitidea点击:

how to get number of the day from date?

phpdateformula

提问by duncanportelli

how to get number of the day from a date in php?
for example: the date format is given: 4/23/2012and it outputs 1or mondayor mon...

如何从php中的日期获取天数?
例如:日期格式为:4/23/2012,它输出1mondaymon...

THANK YOU!

谢谢你!

回答by Ayman Safadi

Try something like:

尝试类似:

<?php

$rawDate = '4/23/2012';

echo date('N', strtotime($rawDate));
?>

Demo here: http://ideone.com/jICqh

演示在这里:http: //ideone.com/jICqh

Checkout PHP's date()functiondocumentation for more ways to format dates.

查看PHP 的date()函数文档,了解更多格式化日期的方法。

回答by duncanportelli

$date = '2007/08/30'; 
$weekday = date('l', strtotime($date)); // note: first arg to date() is lower-case L 

回答by MarcinJuraszek

回答by Jan

it depends on the number you want, the number of the day of the current month or the day of the actual year. See the date functionfor details.

这取决于您想要的数字,当前月份的日期或实际年份的日期。有关详细信息,请参阅日期函数