Hello,
I've a date formatted like "Tue Jan 05 11:08:27 +0000 2010" and I want to convert it's format to "yyyy-mm-dd 00:00" in PHP.
How can I do that?
Hello,
I've a date formatted like "Tue Jan 05 11:08:27 +0000 2010" and I want to convert it's format to "yyyy-mm-dd 00:00" in PHP.
How can I do that?
convert it to a PHP date object with strtotime() then output it with date()
EDIT
Some more detail; try:
$time = strtotime('Tue Jan 05 11:08:27 +0000 2010');
echo date("Y-m-d h:i", $time);
Y = 4 digit year m = 2 digit month (with leading 0) d = 2 digit month (with leading 0)
h = 12 hour time (leading 0) i = minutes (with leading 0)
http://php.net/manual/en/function.date.php for all the formatting options
$time_string = 'Tue Jan 05 11:08:27 +0000 2010';
$formated_time = date('Y-m-d h:i', strtotime($time_string));
echo $formated_time;
Agree with Erik, if you want to do it in one line.
Solution
$date = date('Y-m-d H:i:s', strtotime('Tue Jan 05 11:08:27 +0000 2010'));