如何在php中获得最早的日期时间? [英] How do I get the earliest possible datetime in php?
本文介绍了如何在php中获得最早的日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的理解是,php中的日期时间表示为某个日期后的毫秒数(我认为是1960年的某个时间?).我该如何构造一个代表php中最早允许日期的datetime?可能的语法示例为:
My understanding is that datetimes in php are represented as the number of milliseconds after a certain date (some time in 1960 I think?). How to I construct a datetime that represents the earliest allowable date in php? An example possible syntax would be:
$date = new DateTime(0);
但这是行不通的.还有其他方法吗?
but this doesn't work. Is there some other way to do this?
感谢您的任何输入.
推荐答案
您非常接近
$date = (new DateTime())->setTimestamp(0);
将给出1970年1月1日
Will give January 1st, 1970
这篇关于如何在php中获得最早的日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文