简体   繁体   中英

Date format in php using regular expression

Hai,任何可以帮助我使用PHP中的正则表达式将“Wed Sep 29 14:47:37 +0000 2010”改为 2010年9月29 日下午2:47”

You can use strtotime . No need for regular expression.

date('M j, Y \a\t g:i A', strtotime('Wed Sep 29 14:47:37 +0000 2010'));

Use the functions date and strtotime :

$str = 'Wed Sep 29 14:47:37 +0000 2010';
$timestamp = strtotime($str);

echo date('M j, Y', $timestamp).' at '.date('g:i A', $timestamp);;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM