cgm225 Posted July 6, 2007 Share Posted July 6, 2007 How can I convert the following date format: 7.4.2007 to RSS format: Wed, 4 Jul 2007 Thank you all in advance! Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/ Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 echo date("j, n, Y"); Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291662 Share on other sites More sharing options...
cgm225 Posted July 6, 2007 Author Share Posted July 6, 2007 Well if I have 7.4.2007, how would I convert that..? Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291664 Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 echo date("j. n. Y"); ;D ;D ;D ;D Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291667 Share on other sites More sharing options...
cgm225 Posted July 6, 2007 Author Share Posted July 6, 2007 Yes, that echoes the current date, but what it I have some variable set as 7.4.2007, how would I convert that to the corresponding RSS date format, so, with this example, Wed, 4 Jul 2007 Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291672 Share on other sites More sharing options...
teng84 Posted July 7, 2007 Share Posted July 7, 2007 echo date("m.d.Y", strtotime('june 7 2007')); Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291677 Share on other sites More sharing options...
Barand Posted July 7, 2007 Share Posted July 7, 2007 strtotime() recognises some formats and not others, so playing safe <?php $date = '7.4.2007'; list ($m, $d, $y) = explode ('.', $date); // swap $m and $d if using d.m.yyyy format $rss_date = date('D, j M Y', strtotime("$y-$m-$d")); echo $rss_date; ?> Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291804 Share on other sites More sharing options...
cgm225 Posted July 7, 2007 Author Share Posted July 7, 2007 Exactly what I needed. Thank you!! Link to comment https://forums.phpfreaks.com/topic/58785-solved-converting-date-format/#findComment-291905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.