What's the oldest and newest dates representable by PHP datetime?

136
March 17, 2019, at 03:10 AM

Let's assume a 64 bit version of PHP in case that matters

I'm thinking about generating a random datetime but I realised I don't know how far back in time or how far forward in time the min-max possible values for datetime are to use as min-max for random

Answer 1
<?php
$min = \date_create('@' . PHP_INT_MIN);
var_dump($min->format('Y-m-d H:i:s'));
$max = \date_create('@' . PHP_INT_MAX);
var_dump($max->format('Y-m-d H:i:s'));
$diff = \date_diff($min, $max);
echo $diff->format("%R%a days");

https://3v4l.org/8N17M

This is the earliest and furthest datetime I've found so far

Not sure why I'm getting 0 days in the diff though

Rent Charter Buses Company
READ ALSO
Retrofit Post Data is not received by PHP

Retrofit Post Data is not received by PHP

i want to update a table by using retrofit, so i have an API as follows

89
Json Object Sorting in Php [on hold]

Json Object Sorting in Php [on hold]

I m not professional and i have a problemI call assists created with json object in database

150
Reverse row &ldquo;order&rdquo; value from table MySQL with PHP

Reverse row “order” value from table MySQL with PHP

I have a table with rows and each one has an "order" valueNow, I have like 500 rows and I need to reverse the "order" values

177
Remove all elements from XML that match specific strings in a node with PHP

Remove all elements from XML that match specific strings in a node with PHP

I need to remove some elements that match specific strings on an XML using PHP, I guess I can do this with DOM as I have been readingThe problem comes using multiple strings

112