php php中的日期到日期的转换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1062196/
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
Date to day conversion in php
提问by Sakthivel
in my webpage i need to calculate the day[ie. SUN,MON,TUE...] from the date .. The date is in ['06/22/2009'] this format ? How can i calculate it in to day[That is it will show me MON] in php . Please help me to find out . Thanks in advance..
在我的网页中,我需要计算天[即。SUN,MON,TUE...] 从日期 .. 日期为 ['06/22/2009'] 这种格式?我怎样才能在 php 中计算它[也就是说它会显示我 MON] 。请帮我找出来。提前致谢..
回答by harto
First, you need to parse the string '06/22/2009' into a timestamp, possibly using strtotime():
首先,您需要将字符串 '06/22/2009' 解析为时间戳,可能使用strtotime():
$dt = strtotime('06/22/2009');
Then, you can format the timestamp using date():
然后,您可以使用date()以下格式格式化时间戳:
$day = date("D", $dt);
If you especially want it in uppercase, use strtoupper():
如果您特别想要大写,请使用strtoupper():
print strtoupper($day);
回答by Charles Ma
Use the date http://au.php.net/manual/en/function.date.phpand strtotime http://au.php.net/strtotimefunctions
使用日期 http://au.php.net/manual/en/function.date.php和 strtotime http://au.php.net/strtotime函数
回答by Mahfuzur Rahman
For future viewers, I think this will be more helpful.
对于未来的观众,我认为这会更有帮助。
echo date('l', strtotime('11/20/2017'));
回答by nelson prabu
pls check the funcion. the out put is showing the current day.pls tell me the given date dau in the date("D",$dat)
请检查功能。输出显示当前日期。请告诉我给定的日期 dau 在date("D",$dat)

