Date format
Moderator: General Moderators
Date format
Hello. I'm pulling a date from a database through the php. When I pull it up it will say something like 2009-06-02. What I want it to do is to put it "February the 6th 2009". How can I do that? Thanks!
Re: Date format
You can do it in your database query: http://dev.mysql.com/doc/refman/5.1/en/ ... ate-format
Otherwise you can use strtotime() and date() to format the date.
Otherwise you can use strtotime() and date() to format the date.
Re: Date format
I've been looking but I havent found what is the right code for the format that I want. Can you help me? Thanks!
Re: Date format
It's right on the page I sent you for the mysql method. For the php method you can go to php.net and search for date. That will show you a chart of the different keys used for formatting the date.
Re: Date format
Lol! I'm sorry, but I honestly cannot see the format that I want there or in the php.
Re: Date format
You'll have to use the keys to format the date yourself. For example, Y stands for the 4 digit year.
Re: Date format
Code: Select all
<?php
$timer_given = '2009-06-02';
$my_time = strtotime($timer_given);
$my_date = date('d:F:Y',$my_time);
echo $my_date; //gives you the required time
//echo $my_time;
?>