PHP microtime() Function6 Jan 2025 | 1 min read The PHP microtime() function is used to returns the current Unix timestamp with microseconds. Float value is return by this function. SyntaxParameters
ReturnThis function returns a string in the form "msec sec", where sec is the number of seconds, and msec measures microseconds that have elapsed since sec and is also expressed in seconds. Example 1Output: Did nothing in 0.0002589225769043 seconds Example 2Output: Did nothing in 0.0019979476928711 seconds Next TopicPhp-mktime-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
PHP date_interval_format() for formatting the interval, this function is used in the script. We can also write it as DateInterval::format(). Syntax DateInterval::format(format); Note: Here format is the required string. Return This function returns the formatted interval. Example 1 <?php $date1=date_create("2018-01-01"); $date2=date_create("2018-02-10"); $diff=date_diff($date1,$date2); echo $diff->format("Total number of days: %a."); echo "\n"; echo $diff->format("Total number of days: %R%a."); echo "\n"; echo $diff->format("Month:...
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
This getdate() function is used to get the information of the current local date/time or the timestamp. Syntax array getdate ([ int $timestamp = time() ] ) Parameters Parameter Description Required/Optional timestamp Specifies an integer optional Return This function returns an associative array of information related to the timestamp. Example 1 <?php $todaydate=getdate(date("U")); echo "$todaydate[weekday], $todaydate[month] $todaydate[mday], $todaydate[year]"; ?> Output: Thursday, August 2,...
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
This function sets the default timezone. It is used by all the date and time functions of the PHP. Syntax bool date_default_timezone_set ( string $timezone_identifier ) Parameters timezone_identifier: The timezone identifier like UTC or Europe/Lisbon. The list of valid identifiers is available in the List of Supported Timezones. Return This function...
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
The PHP timezone_offset_get() function is used to show the offset of the timezone from the GMT. Syntax int timezone_offset_get ( $object, $datetime ); Parameters Parameter Description Required/Optional object Specifies a DateTimeZone object required datetime Specifies a date/time required Return This function returns time zone offset in seconds on success or FALSE on failure. Example 1 <?php $timezone=timezone_open("Asia/Taipei"); $dateTimeOslo=date_create("now",timezone_open("Europe/Oslo")); echo timezone_offset_get($timezone,$dateTimeOslo); ?> Output: 28800 Example 2 <?php $timezone=timezone_open("Africa/Juba "); $dateTimeAmsterdam=date_create("now",timezone_open("Europe/Amsterdam ")); echo...
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
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