[英]PHP Convert separate day,month and year to date
I looked in many threads regarding this issue but still can't get to the bottom of this one.我查看了许多关于这个问题的线程,但仍然无法深入了解这个问题。 Here is my code:
这是我的代码:
$birthdate_ts = strtotime("$year-$num_month-$day");
$birthdate = date("d/m/Y",$birthdate_ts);
Where $day $num_month and $year are numbers (example 1 10 1990).其中 $day $num_month 和 $year 是数字(例如 1 10 1990)。 The result I'm getting is 1/1/1970 every time.
我得到的结果每次都是 1/1/1970。 I also tried different variations for the "strtotime()" input and still nothing.
我还尝试了“strtotime()”输入的不同变体,但仍然没有。 Where am I wrong?
我哪里错了?
Your parse format is "d/m/y" and your format you are creating is "Ymd".您的解析格式是“d/m/y”,您创建的格式是“Ymd”。 They need to match.
他们需要匹配。 Try this:
尝试这个:
$birthdate_ts=strtotime("$year-$num_month-$day");
$birthdate=date("Y-m-d",$birthdate_ts);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.