Dennis found this little nugget in an application he inherited.
function myTime(){
$utc_str = gmdate("M d Y H:i:s", time());
$utc = strtotime($utc_str);
return $utc;
}
time()
returns the current time as a Unix timestamp. gmdate
then formats that, with the assumption that the time is in GMT. strtotime
then parses that string back into a timestamp, and returns that timestamp.
Notably, PHP pins the Unix timestamp to UTC+00:00, aka GMT. So this function takes a time, formats it, parses the format to get what should be the same time back.
And we call the function myTime
because of course we do. When reinventing a wheel, but square, please do let everyone know that it’s yours.
[Advertisement]
Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Source: Read MoreÂ