PHP date_modify() function6 Jan 2025 | 1 min read This function allows the modification in date and time. SyntaxParameters
ReturnThis function returns NULL on success or FALSE on failure. Example 1Output: 2018-05-16 Example 2Output: 2020-12-22 Example 3Output: 2020-12-02 Next TopicPhp-date-offset-get-function |
This PHP localtime() function is used to print the time in the form of indexed and associative array. It returns the local time. Syntax localtime(timestamp,is_assoc); Parameters Parameter Description Required/Optional timestamp Specifies a Unix timestamp optional Is_assoc Specifies whether to return an associative array or indexed array. optional Example 1 <?php print_r(localtime()); echo "<br><br>"; print_r(localtime(time(),true)); ?> Output: Array ( [0] => 45 ...
2 min read
The date_timestamp_get() function is used to return the Unix timestamp for today's date and time. Syntax date_timestamp_get(object); 0r DateTime::getTimestamp() Parameters Parameter Description Required/Optional object Specifies a DateTime object required Example 1 <?php $date=date_create(); echo date_timestamp_get($date); ?> Output: 1533132945 Example 2 <?php $date = new DateTime(); echo $date->getTimestamp(); ?> Output: 1533133630 TopicPhp-date-timezone-get-function ...
1 min read
The gmdate() function is used to changethe GMT/UTC date and time and output is returned in form of data string. It also modifies the date and time format in readable form. Syntax string gmdate ( string $format [, int $timestamp = time() ] ) Parameters Parameter Description Required/Optional Format Specifies the format of...
1 min read
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
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
PHP time and date functions informus about current date and time. Time and date can be manipulated by using these functions. 02 Nov - PHP checkdate() Function 02 Nov - PHP date() Function 02 Nov - PHP date_add() Function 02 Nov - PHP date_create() Function 02 Nov - PHP date_date_set()...
2 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
The gmmktime() function is used to find the day of that particular date. It returns the returns the Unix timestamp for a GMT date. Syntax int gmmktime(hour,minute,second,month,day,year,is_dst); Parameters Parameter Description Required/Optional Hour Specifies the hour optional Minute Specifies the minute optional Second Specifies the second optional Month Specifies the month optional Day Specifies the day optional Year Specifies the year optional Is_dst specifies a GMT date optional Return This function returns an integer Unix...
1 min read
This function clears the date and year exit or not. Syntax bool checkdate ( int $month , int $day , int $year ) Parameters Parameter Description month The month is between 1 and 12 inclusive. day The day is within the allowed number of days for the given month. year The year is between 1 and...
1 min read
This function is used when a certain amount of time is added or subtracted from the standard UTC to get the current civil time that had been already set on DST(daylight saving time). Syntax int date_offset_get ( DateTime $object ) Parameters Parameter Description Required/Optional Object Specifies a DateTime object Required Return This function returns DST offset...
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