springo Posted April 8, 2007 Share Posted April 8, 2007 Hi, I was looking forward to changing a string as "Apr 09" to "04/09". I first thought about switching through the months and preg_matching the day, and then I saw date() and strtotime(), but I don't really know if strtotime() will work with my input. How could I actually do this? Thanks! Link to comment https://forums.phpfreaks.com/topic/46194-changing-time-format/ Share on other sites More sharing options...
Barand Posted April 8, 2007 Share Posted April 8, 2007 Well, you could always do what I just did - try it! <?php $str = 'Apr 09'; echo date ('m/d', strtotime($str)); //--> 04/09 ?> Link to comment https://forums.phpfreaks.com/topic/46194-changing-time-format/#findComment-224575 Share on other sites More sharing options...
springo Posted April 8, 2007 Author Share Posted April 8, 2007 Whew strtotime() is a powerful function, it worked it out by itself! Thanks! Link to comment https://forums.phpfreaks.com/topic/46194-changing-time-format/#findComment-224577 Share on other sites More sharing options...
Barand Posted April 9, 2007 Share Posted April 9, 2007 Not all formats work, eg European dd/mm/yy formats don't Link to comment https://forums.phpfreaks.com/topic/46194-changing-time-format/#findComment-224580 Share on other sites More sharing options...
springo Posted April 9, 2007 Author Share Posted April 9, 2007 Hopefully I didn't need that at this time, but I'll keep record of that. Link to comment https://forums.phpfreaks.com/topic/46194-changing-time-format/#findComment-224586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.