Home > Backend Development > PHP Tutorial > PHP format date and time formatting example sharing_PHP tutorial

PHP format date and time formatting example sharing_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:24:56
Original
880 people have browsed it

Copy code The code is as follows:

// Format date
static function formatDate($format, $datetime, $week = 0) {
$datetime = $datetime > 3000 ? $datetime : strtotime($datetime);
if ($week) {
$weeknames = [
‘Day’,
'One',
'Two',
'Three',
'Four',
'Five',
      'Liu'
                                                                             format = str_replace('w', $weeknames [date('w', $datetime)], $format);
}
return date($format, $datetime);
}

Copy code The code is as follows:
echo "week" . formatDate("w","2012-11-03 00 :46:22" , 1) . " " . formatDate("Y-m-d", "2012-11-03 00:46:22");
echo "week" . formatDate("w","1388678400" , 1) . " " . formatDate("Y-m-d", "1388678400");
Saturday 2012-11-03

Friday 2014-01-03

http://www.bkjia.com/PHPjc/825268.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825268.htmlTechArticleCopy the code as follows: // Format date static function formatDate($format, $datetime, $week = 0 ) { $datetime = $datetime 3000 ? $datetime : strtotime($datetime); if ($week)...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template