dadedidhodong Posted August 19, 2013 Share Posted August 19, 2013 I have a php program which accepts the input of the YYYY-MM-DD as the date format and stores it to the database. As soon as the user enters the date with YYYY-MM-DD format (e.g 1990-06-22) how can I convert the 06 (or the MM part) to June as in the 6th month of the year? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted August 19, 2013 Share Posted August 19, 2013 Is there a reason why you don't want to store the date as YYYY-MM-DD? That format is more useful for things like sorting. When displaying the data, you could always use MySQL's date_format() function: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format Quote Link to comment Share on other sites More sharing options...
incipience Posted August 19, 2013 Share Posted August 19, 2013 <?php $date = new DateTime('2000-01-01'); echo $date->format('F j, Y'); ?> This would display as January 1, 2000 Quote Link to comment Share on other sites More sharing options...
Evan_McIntosh Posted August 19, 2013 Share Posted August 19, 2013 (edited) <?php date_default_timezone_set('America/Vancouver'); $date = '2099-12-31'; echo date('F j, Y', strtotime($date)); ?> = December 31, 2099 http://php.net/manual/en/function.date.php http://php.net/manual/en/function.strtotime.php Edited August 19, 2013 by Evan_McIntosh Quote Link to comment Share on other sites More sharing options...
Solution dadedidhodong Posted August 23, 2013 Author Solution Share Posted August 23, 2013 thank you very much guyz :] Quote Link to comment 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.