Re: Date format question
| From: | Justin French | Date: | Tue, 25 Nov 2003 03:04:01 +0000 |
| Subject: | Re: Date format question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170841@lists.php.net to get a copy of this message | ||
On Tuesday, November 25, 2003, at 01:42 PM, Manisha Sathe wrote:
I have a date returned from MySQL in 'YYYY-MM-DD' format, i want to show this date in 'DD/MM/YYYY' format using PHP, date() function does the same if i pass timestamp in int format, but how to convert into int timestamp ? e.g from '2003-11-25' to '20031125' ? and Then I believe that i can use date ("d/m/Y", '20031125' ) to the things done ?<? // the original $mysql_date = '2003-11-25'; // convert to a unix timestamp (seconds since 1970) $mysql_date_stamp = strtotime($mysql_date); // pass $mysql_date_stamp to date() as 2nd parameter $human_date = date('d/m/Y',$mysql_date_stamp); echo $human_date; ?> or simplified: <? $original = '2003-11-25'; echo date('d/m/Y', strtotime($original)); ?> Justin French