PHP time() Function12 Jan 2025 | 1 min read The PHP time() function is used to return the current time as a UNIX timestamp. This function would work by our server time and can be formatted easily. SyntaxExample 1Output: 1533574329 2018-08-06 Example 2Output: 1533803143 August 09, 2018 08:25:43 AM Example 3Output: 1532542416 Note: the output of the code is not a human readable code so to get the readable code view next example.Example 4Output: 25/ 07/18 06:13:36 Next TopicPhp-timezone-abbreviations-list-function |
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
The date_sun_info() function is used to return all the information about twilight begin/end and sunset/sunrise time for a specific time and location. Syntax array date_sun_info ( int $time , float $latitude , float $longitude ) Note :here value of latitude is 31.7667 and longitude is 35.2333. Parameters Parameter Description Required/Optional timestamp Specifies a timestamp Required latitude Specifies...
1 min read
The date_sub() function is used to subtracts or deduce some formatted data of the date i.e date, month,year, hours,minutes, seconds etc. Syntax date_sub(object,interval); Parameters Parameter Description Required/Optional Object Specifies a DateTime object required Interval Specifies a DateInterval object required Example 1 <?php $date=date_create("2018-07-15"); date_sub($date,date_interval_create_from_date_string("10 days")); echo date_format($date,"Y-m-d"); ?> Output: 2018-07-05 Example 2 <?php $date=date_create("2020-12-15"); date_sub($date,date_interval_create_from_date_string("5 days")); echo date_format($date,"Y-m-d"); ?> Output: 2020-12-10 Example 3 <?php $date = date_create('2018-07-15'); date_sub($date, date_interval_create_from_date_string('5 years')); echo date_format($date, 'Y-m-d') . "\n"; ?> Output: 2013-07-15 Example 4 <?php $date1...
1 min read
This date_timezone-get() function is used to return the time zone of the given DateTime object in the script. Syntax DateTimeZone date_timezone_get ( DateTime $object ) Parameters Parameter Description Required/Optional object Specifies a DateTime object required Return Values This function returns the DateTimeZone object on success or FALSE on failure. Example 1 <?php $date1=date_create(null,timezone_open("Indian/Maldives")); $ind=date_timezone_get($date1); echo timezone_name_get($ind); ?> Output: Indian/Maldives Example 2 <?php $date1=date_create(null,timezone_open("Pacific/Easter")); $paci=date_timezone_get($date1); echo timezone_name_get($paci); ?> Output: Pacific/Easter Example 3 <?php $date1=date_create(null,timezone_open("Europe/Istanbul")); $eu=date_timezone_get($date1); echo timezone_name_get($eu); ?> Output: Europe/Istanbul ...
1 min read
This function is used to return date in a specified formati.e format of year ,month and day . Syntax string date_format ( DateTime $object, string $format ) Parameters Parameter Description Required/Optional object Specifies Datetime object required format Specifies the format for the date required Return This function returns formatted date on success or FALSE on failure. Example 1 <?php $date=date_create("2018-03-15"); echo date_format($date,"Y/m/d H:i:s"); ?> Output: 2018/03/15...
1 min read
This function is used to provide the complete information of a particular date in a specified format and an associative array is returned by it. Syntax date_parse_from_format(format,date); Parameters Parameter Description Required/Optional Format Specifies the format required Date specifies a date required Return This function returns associative array with detailed info about given date. Example 1 <?php print_r(date_parse_from_format("mmddyyyy","05122018")); ?> Output: Array ( [year] => [month] =>...
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 gmstrftime() function is used to set the date and time according to the local settings . It formats the GMT/UTC date and time. Syntax string gmstrftime ( string $format [, int $timestamp = time() ] ) Parameters Parameter Description Required/Optional Format Specifies how to return the result required timestamp Specifies a Unix timestamp that represents...
1 min read
This function allows the modification in date and time. Syntax date_modify(object,modify); Parameters Parameter Description Required/Optional object Specifies a DateTime object return. Required modify Specifies a date/time string Required Return This function returns NULL on success or FALSE on failure. Example 1 <?php $date=date_create("2018-05-01"); date_modify($date,"+15 days"); echo date_format($date,"Y-m-d"); ?> Output: 2018-05-16 Example 2 <?php $date = new DateTime("2020-12-12"); $date->modify("+10 day"); echo $date->format("Y-m-d"); ?> Output: 2020-12-22 Example 3 <?php ...
1 min read
The PHP microtime() function is used to returns the current Unix timestamp with microseconds. Float value is return by this function. Syntax mixed microtime ([ bool $get_as_float = FALSE ] ) Parameters Parameter Description Required/Optional get_as_float specifies that the function should return a float optional Return This function returns a string in the form "msec sec",...
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