[英]How to convert the date time format of 24 hours to 12 hours format
我從這樣的24小時格式的php文件中獲取日期
2015-02-19 22:39:00.000000,我想將此時間格式轉換為12小時格式,例如2015-02-19 10:39:00 PM,如何使用js或php實現此功能...
在php中,您可以這樣實現: $time_in_12_hour_format = date("g:ia", strtotime($yourStringTime));
$date = '2015-02-19 22:39:00.000000';
echo date('Y-m-d h:i:s A', strtotime($date));
輸出:
2015-02-19 10:39:00 PM
$d = strtotime('2015-02-19 22:39:00.000000');
echo date('Y-m-d h:i:s A',$d);
得到:
2015-02-19 10:39:00 PM
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.