ksduded Posted April 24, 2008 Share Posted April 24, 2008 I want to format my date in the form of April 12th 2008. Though I want to pass a variable which has the value '2008-02-12' into the date function and format is as mentioned. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/102727-solved-putting-variable-in-date/ Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 Replace Fomat HERE with the format you want <?php echo date("Format HERE", strtotime('2008-02-12'));?> Link to comment https://forums.phpfreaks.com/topic/102727-solved-putting-variable-in-date/#findComment-526051 Share on other sites More sharing options...
kenrbnsn Posted April 24, 2008 Share Posted April 24, 2008 You need to use the strtotime() function to convert the date string into a form the date() function can use: <?php $date = '2008-02-12'; echo date('F jS Y',strtotime($date)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/102727-solved-putting-variable-in-date/#findComment-526054 Share on other sites More sharing options...
ksduded Posted April 24, 2008 Author Share Posted April 24, 2008 thanks guys, that worked Link to comment https://forums.phpfreaks.com/topic/102727-solved-putting-variable-in-date/#findComment-526069 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.