example:
$date = 'Wed, 18 Feb 2009 16:03:52 GMT';
//How can I get $date to equal the current time in the same format?
example:
$date = 'Wed, 18 Feb 2009 16:03:52 GMT';
//How can I get $date to equal the current time in the same format?
I'm not sure I completely understand, but if you merely want to convert the string, you can use strtotime()
.
I assume you mean how to get similar format as that? As there is no exact match in the predefined date constants, this would do it:
$date = gmdate('D, j M Y H:i:s e');
That would return the current date and time in the same format as 'Wed, 18 Feb 2009 16:03:52 GMT'.
EDIT
GMT and UTC are (in normal cases) completely interchangeable, and as gmdate always returns an GMT/UTC date, you can just use this:
$date = gmdate('D, j M Y H:i:s').' GMT';
Or, as it turns out, you can replace e with T to get GMT:
$date = gmdate('D, j M Y H:i:s T');