Professional Documents
Culture Documents
date_default_timezone_set(string)
getdate (timestamp = time())
Change a time zone within php script
Return time and date information in an array
date_default_timezone_set ('Asia/Jakarta');
$today = getdate();
To change permanently, modify php configuration in the // Array ( [seconds] => 0 [minutes] => 50
php.ini file [hours] => 23 [mday] => 21 [wday] => 2 [mon] = >
3 [year] => 2017 [yday] => 79 [weekday] =>
date.timezone = Asia/Jakarta Tuesday [month] => March [0] => 1490136600 )
Return date in UNIX (GMT + 0) format from particular echo 'Day difference : ' . $diff->days;
string. For string format, see relative format section // Day difference: 10398
strtotime('now'); // 1490135639 Format the output:
date('d-m-Y H:i:s', strtotime('now')); // 22-03-
2017 05:35:04 $diff->format('Your age is %Y years and %d
date('d-m-Y H:i:s', strtotime('+1 day')); // 23- days'); // Your age is 29 years 9 days.
03-2017 05:35:04
Format:
date('d-m-Y H:i:s', strtotime('-24 hours')); //
21-03-2017 05:35:04 %Y for 4 digit year and %y for 2 digit year,
%M for month with leading 0 and %m for month
mktime(hour, min, sec, month, day, year) without leading 0,
%D for day with leading zero and %d for day without
Return date in UNIX (GMT + 0) format leading zero
date('m/d/Y', mktime(0,0,0,1,32,2017)); // %a for total days
02/01/2017
©2017 • WebDevZoom.com
Character for format parameter string ref ›› Relative Format ref ››
Used Symbol
-- Day ---
d 01 to 31 Description Format
A AM or PM
Hour
g 1 through 12
h 01 through 12
G 0 through 23
H 00 through 23
©2017 • WebDevZoom.com