How to get the earliest possible time in php?

I understand that datetimes in php are represented as the number of milliseconds after a certain date (for some time in 1960, I think?). How to create date and time which represents the earliest valid date in php? Possible syntax example:

$date = new DateTime(0); 

but it does not work. Is there any other way to do this?

Thanks for any input.

+4
source share
3 answers

You're pretty close

 $date = (new DateTime())->setTimestamp(0); 

January 1, 1970

+2
source
 echo date('dm-Y', 0); // outputs: 01-01-1970 

epoch 0 gives the unix time stamp 01-01-1970 or 00:00:00 UTC on January 1, 1970.

+1
source

zero is not the lowest time, since the Unix timestamp may be negative,

$ echo '' | php Content type: text / html X-Powered-By: PHP / 4.3.9

14-12-1901 -2147483648

0
source

Source: https://habr.com/ru/post/1258368/


All Articles