且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用php将mysql日期(datetime)转换为更好的日期格式

更新时间:2023-11-29 12:28:58

请参阅 strtotime() date()



例如, 2010-02-03 22:21:26 to 2010年2月3日22:21

  $ DateTimeStr ='2010-02-03 22:21:26'; 
echo date('jS F Y \a\t G:i',strtotime($ DateTimeStr));


I some php code which gets info from a mysql database. The problem is that the date is coming out in the format : "2010-02-03 22:21:26"

Does anyone know a simple solution to make the date more user friendly format. e.g

2nd march 2010 at 22:21.

See strtotime() and date()

e.g., 2010-02-03 22:21:26 to 3rd February 2010 at 22:21:

$DateTimeStr = '2010-02-03 22:21:26';
echo date('jS F Y \a\t G:i', strtotime($DateTimeStr));