PHP date() function6 Jan 2025 | 1 min read PHP date() function shows day, month and year altogether. Date and time are stored in computer in UNIX Timestamp format. It calculates time in number of seconds on GMT (greenwich mean time) i.e started from January 1, 1970, 00:00:00 GMT. SyntaxParameters
ReturnThis function returns a formatted date string. If timestamp is using a non-numeric value, FALSE is returned and an E_WARNING level error is emitted. Example 1Output: 09/08/18 Example 2Output: Thursday Thursday 9th of August 2018 09:16:30 AM Example 3Output: 09/08/2018 09-08-2018 09.08.2018 Next TopicPhp-date-add-function |
This function is used to add the days, months, years to the date. Syntax date_add(object,interval); Parameters Parameter Description object Required. Specifies a DateTime object interval Required. Specifies a DateInterval object Example 1 <?php $datefind=date_create("2018-03-16"); date_add($datefind,date_interval_create_from_date_string("4 days")); echo date_format($datefind,"Y-m-d"); ?> Output: 2018-03-20 Example 2 <?php $date=date_create("2018-12-10"); date_add($date, date_interval_create_from_date_string("2 year ...
1 min read
This PHP timezone_abbreviations_list() function is used to return an associative array that contains the timezone name, offset and the dst. Syntax array timezone_abbreviations_list(); Return This function returns array on success or FALSE on failure. Example 1 <?php $timezone_abbreviations = timezone_abbreviations_list (); print_r($timezone_abbreviations["acst"]); echo "----------------------------------------------\n"; # Using...
9 min read
The PHP strtotime() function is used to convert an English text datetime into a Unix timestamp. Syntax int strtotime ( string $time [, int $now = time() ] ) Parameters Parameter Description Required/Optional Time Specifies a date/time string Required Now A timestamp that calculate relative dates. Optional Return This function returns a timestamp on success, FALSE otherwise. Example 1 <?php echo(strtotime("now") ....
1 min read
The gettimeofday() function is used to get the current time of the day. It returns a float value. Syntax mixed gettimeofday ([ bool $return_float = FALSE ] ) Parameters Parameter Description Required/Optional return_float Specifies a float value optional Return This function by default returns an array. If return_float is set, this function will return a float. Example...
1 min read
The PHP timezone_name_get() function is used to show name of timezone. Syntax tring timezone_name_get ( DateTimeZone $object ); Parameters object: It is the date and time zone object. Return This function returns array on success or FALSE on failure. Example 1 <?php $timezone=timezone_open("Europe/Paris"); echo timezone_name_get($timezone); ?> Output: Europe/Paris Example 2 <?php $timezone=timezone_open("Africa/Juba "); echo timezone_name_get($timezone); ?> Output: Africa/Juba TopicPhp-timezone-offset-get-function ...
1 min read
The PHP timezone_version_get() function is used to get the version of the timezone . Syntax string timezone_version_get ( void ) Return This function returns a string. Example <?php echo timezone_version_get(); ?> Output: 0.system TopicJava Methods List ...
1 min read
This PHP timezone_open() function is used to return the name of the timezone and also create a new DateTimeZone object. Syntax timezone_open ( $timezone ) Parameters timezone: It specifies a timezone. Return This function returns the DateTimeZone object on success or FALSE on failure. Example 1 <?php $timezone=timezone_open("Europe/Paris"); echo timezone_name_get($timezone); ?> Output: Europe/Paris Example 2 <?php $timezone=timezone_open("Europe/Oslo"); echo timezone_name_get($timezone); ?> Output: Europe/Oslo TopicPhp-timezone-version-get-function ...
1 min read
The date_timestamp_set() function is used to set the date and time based on unix timestamp. It returns a datetime object and unix timestamp represents the date. Syntax date_timestamp_set(object,unixtimestamp); Parameters Parameter Description Required/Optional object Specifies a DateTime object required unixtimestamp Specifies a Unix timestamp representing the date optional Example 1 <?php $date1=date_create(); date_timestamp_set($date1,1533132945); echo date_format($date1,"U = Y-m-d H:i:s"); ?> Output: 1533132945 = 2018-08-01 14:15:45 Example 2 <?php $date=date_create(); date_timestamp_set($date,1533133630); echo date_format($date,"U...
1 min read
This date_sunset() function is used to get the timing of sunset of a particular day and location. This function returns the sunset time of different locations. Syntax mixed date_sunset ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude")...
1 min read
The date_time_set() function is used to set the time in a specified format. It returns a datetime object at the end. Syntax date_time_set(object,hour,minute,second); Parameters Parameter Description Required/Optional object Specifies a DateTime object required hour Specifies the hour of the time Specifies the hour of the time minute Specifies the minute of the time required second Specifies the second of the time optional Example 1 <?php $date1=date_create("2018-7-31"); date_time_set($date1,10,24); echo...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India