Format a date string in PHP
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If I have a string which represents a date, like "2011/07/01" (which is 1st July 2011) , how would I output that in more readable forms, like: 1 July 2011 1 Jul 2011 (month as three letters) And also, how could I make it intelligently show date ranges like "2011/07/01" to "2011/07/11" as 1 - 11 July 2001 (without repeating the 'July' and '2011' in this case) 回答1: As NullUserException mentioned, you can use strtotime to convert the date strings to timestamps. You can output 'intelligent' ranges by using a different date format for the first