The format of the outputted date string.date_default_timezone_set — Sets the default timezone used by all date/time functions in a script.We use this because some time its necessary to store date when some user event occur and we need to store this to particular database and many more
1: // set the default timezone to use. Available since PHP 5.1
2: date_default_timezone_set('UTC');
3:
4: //Set date function according to: IST(Indian Standard Time )
5: date_default_timezone_set('Asia/Kolkata');
6: $today=date("Ymd"); //date function is used here
7:
8: echo $today; //will prints date in string like structure
9: //ex.-20121227 for 27th Dec.2012
Ex.
<?php
$timezone=date_default_timezone_get();
echo $timezone."<br>";
print strftime('%c')."<br>";
$timezone1=date_default_timezone_set('Asia/Calcutta');
echo $timezone1."<br>";
print strftime('%c');
?>
Output
America/New_York
Fri Dec 28 00:25:54 2012
1
Fri Dec 28 10:55:54 2012


