yukafluck Posted May 24, 2009 Share Posted May 24, 2009 Ok I have two things that I want to do: 1. I have a field in my database that is a birthdate. It gets displayed as yyyy-mm-dd, and I want to change it to ie*january 1, 2009. How can this be done. 2. I want to be able to have that date match today's date without the year coming into effect. any help or direction to a tutorial on this would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/ Share on other sites More sharing options...
Axeia Posted May 24, 2009 Share Posted May 24, 2009 You might want to mention which database you're using as they all seem to have a different way when it comes to date. At least that's my painful experience today after having to write queries that work with dates and need to work on derby, mysql and postgresql (while originally being written for sqlite). Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-841391 Share on other sites More sharing options...
yukafluck Posted May 24, 2009 Author Share Posted May 24, 2009 My bad, I am using mysql. I am inputing the information through PHPmyadmin. Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-841395 Share on other sites More sharing options...
Ken2k7 Posted May 25, 2009 Share Posted May 25, 2009 Something like this - SELECT * FROM tablename WHERE DATE_FORMAT(birthdate, '%m-%d') = DATE_FORMAT(CURDATE(), '%m-%d') ? Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-841436 Share on other sites More sharing options...
gnawz Posted May 25, 2009 Share Posted May 25, 2009 Not sure what you want. Check out... www.php.net/manual/en/function.date.php There are very many ways to deal with date using PHP's date() function Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-841441 Share on other sites More sharing options...
yukafluck Posted May 25, 2009 Author Share Posted May 25, 2009 Maybe i should have put this into two posts, let me deal with the first, then I will post a second one for the other issue. I have in my code <?php echo $bday; ?> [code=php:0] And the output on the page comes as :1968-01-02 but I want it to come out as: January 2, 1968. Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-841780 Share on other sites More sharing options...
gnawz Posted May 25, 2009 Share Posted May 25, 2009 <? $bday = date("F d,Y"); echo $bday; ?> Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-841924 Share on other sites More sharing options...
tukangnggame Posted May 26, 2009 Share Posted May 26, 2009 Ok I have two things that I want to do: 1. I have a field in my database that is a birthdate. It gets displayed as yyyy-mm-dd, and I want to change it to ie*january 1, 2009. How can this be done. 2. I want to be able to have that date match today's date without the year coming into effect. any help or direction to a tutorial on this would be greatly appreciated. 1. Don't change, but just query to display it SELECT DATE_FORMAT(your_date, '%M %e, %Y') AS yourdate FROM your_table Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-842075 Share on other sites More sharing options...
yukafluck Posted May 26, 2009 Author Share Posted May 26, 2009 figured it out: this worked <?php echo strftime("%B %d , %G", $bday); ?> [code=php:0] Quote Link to comment https://forums.phpfreaks.com/topic/159512-solved-format-date/#findComment-842582 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.