1
2011-07-13 02:38:31

^ MySQL format.

I would like to use PHP to convert it to another format like , July 13, 2011 2:38 am.

Ryan
  • 14,392
  • 8
  • 62
  • 102
  • possible duplicate of [How to format this date (dd/mm/yyyy) into (j M Y) in PHP?](http://stackoverflow.com/questions/6692294/how-to-format-this-date-dd-mm-yyyy-into-j-m-y-in-php) – genesis Jul 17 '11 at 18:31
  • check this: [http://stackoverflow.com/questions/2487921/php-convert-date-format-yyyy-mm-dd-dd-mm-yyyy-not-in-sql][1] [1]: http://stackoverflow.com/questions/2487921/php-convert-date-format-yyyy-mm-dd-dd-mm-yyyy-not-in-sql – Tepken Vannkorn Jul 17 '11 at 18:33
  • check this: [http://stackoverflow.com/questions/2487921/php-convert-date-format-yyyy-mm-dd-dd-mm-yyyy-not-in-sql][1] [1]: http://stackoverflow.com/questions/2487921/php-convert-date-format-yyyy-mm-dd-dd-mm-yyyy-not-in-sql – Tepken Vannkorn Jul 17 '11 at 18:34

3 Answers3

5
<?php
$time_from_db = '2011-07-13 02:38:31';

echo date('F j, Y g:i a', strtotime($time_from_db));
?>
Shef
  • 44,808
  • 15
  • 79
  • 90
4
echo date("F j, Y g:i a", strtotime("2011-07-13 02:38:31"));

demo

genesis
  • 50,477
  • 20
  • 96
  • 125
1
$yourdatevar = date("F j, Y, g:i a", strtotime($yourdatevar)); // March 10, 2001, 5:16 pm

Taken right from: http://php.net/manual/en/function.date.php

Francois Deschenes
  • 24,816
  • 4
  • 64
  • 61
Leopold Stotch
  • 1,452
  • 2
  • 13
  • 24