PHP date_sub() Function6 Jan 2025 | 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. SyntaxParameters
Example 1Output: 2018-07-05 Example 2Output: 2020-12-10 Example 3Output: 2013-07-15 Example 4Output: 2018-04-15 Next TopicPhp-date-sun-info-function |
It is used to set a new date and formatting of date is also allowed. It returns a datetime object. Syntax void date_date_set ( DateTime $object, int $year, int $month, int $day ); Parameters Parameter Description object Required. Specifies a DateTime object returned year Required. Specifies the year of the date month Required. Specifies the 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
This function returns the default timezone. It is used by all the date and time functions of the PHP. Note : timezone will be returned as a string. Syntax string date_default_timezone_get ( void ) Return This function returns a string. Example 1 <?php echo date_default_timezone_get(); ?> Output: UTC Example 2 <?php ...
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 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
This function is used to set the date. All the dates are set according to the ISO 8601 standard and that uses weeks and offsets. Syntax date_isodate_set(object,year,week,day); Parameters Parameter Description Required/Optional Object Specifies a DateTime object returned Required year Specifies the year of the date Required week Specifies the week of the date Required day Specifies the offset from the first day...
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. Syntax int time ( void ) Example 1 <?php $today=time(); echo($today . "\n"); echo(date("Y-m-d",$today)); ?> Output: 1533574329 2018-08-06 Example 2 <?php $time1 = time(); echo($time1); echo "\n"; echo(date("F d, Y h:i:s A", $time1)); ...
1 min read
The strftime() function is used to set the date and time according to the local settings . It formats the GMT/UTC date and time. Syntax string strftime ( string $format [, int $timestamp = time() ] ) Parameters Parameter Description Required/Optional Format Specifies how to return the result required Timestamp Specifies a Unix timestamp optional Return This function returns...
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
This date_sunrise() function is used to get the timing of sunrise of a particular day and location. This function returns the sunrise time of different locations. Syntax mixed date_sunrise ( int $timestamp [, int $format [, float $latitude [, float $longitude [, float $zenith...
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