php格式化日期和时间格式化示例分享
代码如下:
// 格式化日期 static function formatDate($format, $datetime, $week = 0) { $datetime = $datetime > 3000 ? $datetime : strtotime($datetime); if ($week) { $weeknames = [ '日', '一', '二', '三', '四', '五', '六' ]; $format = str_replace('w', $weeknames [date('w', $datetime)], $format); } return date($format, $datetime); }
代码如下:
echo "周" . formatDate("w","2012-11-03 00:46:22" , 1) . " " . formatDate("Y-m-d", "2012-11-03 00:46:22"); echo "周" . formatDate("w","1388678400" , 1) . " " . formatDate("Y-m-d", "1388678400"); 周六 2012-11-03 周五 2014-01-03
相关推荐
Crazyshark 2020-11-13
缘起宇轩阁 2020-08-15
清风徐来水波不兴 2020-01-14
xishizhaohua 2019-11-19
Nicolase 2019-11-06
左转有出口 2013-10-18
zhangkala 2018-08-05
yuwinter 2012-05-16
CCxiaotang 2009-11-26
zhangwei0php 2019-04-16
phptyong 2019-04-15
的砖栏 2019-04-11
phptyong 2019-04-11
phpyounger 2019-04-10
phpcrazy 2013-12-05