Gruzin Posted February 18, 2007 Share Posted February 18, 2007 Hi guys, I have a string (date) with the following formatting: 2011-10 2008-07 2009-09 and so one... Can I display it like this: 09-2009 (month, year). Thanks a lot, George Link to comment https://forums.phpfreaks.com/topic/39031-php-string-manipulation/ Share on other sites More sharing options...
trq Posted February 18, 2007 Share Posted February 18, 2007 <?php $s = "2011-10"; $a = explode('-',$s) echo $a[1].'-'.$a[0]; ?> Link to comment https://forums.phpfreaks.com/topic/39031-php-string-manipulation/#findComment-187954 Share on other sites More sharing options...
kenrbnsn Posted February 18, 2007 Share Posted February 18, 2007 Yes, one way is to use a combination of the date() and strtotime() functions: <?php $str = "2007-11"; echo date('m-Y',strtotime($str)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/39031-php-string-manipulation/#findComment-187956 Share on other sites More sharing options...
Gruzin Posted February 18, 2007 Author Share Posted February 18, 2007 Great, it works just fine Thanks guys! Link to comment https://forums.phpfreaks.com/topic/39031-php-string-manipulation/#findComment-187967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.