w3resource

PHP: idate() function

Description

The idate() function is used to get a local time/date format as an integer.

Version:

(PHP 4 and above)

Syntax:

idate(format, timestamp) 

Parameters:

Name Description Required /
Optional
Type
format B - Swatch Beat/Internet Time
d - Day of the month
h - Hour (12-hour format)
H - Hour (24-hour format)
i - Minutes
I - returns 1 when DST is activated otherwise 0
L - returns 1 for leap year otherwise 0
m - Month number
s - Seconds
t - Days in current month
U - Seconds since the Unix Epoch - January 1 1970 00:00:00 UTC
w - Day of the week (0 on Sunday)
W - ISO-8601 numeric week of year, weeks starting on Monday
y - Year
Y - Year in 4 digits
z - Day of the year
Z - Timezone offset in seconds

Optional String
timestamp An integer indicates the unixtimestamp. If a timestamp is not supplied, it gives the current local time. Optional integer

Return value:

An integer value.

Value Type: Integer.

Example:

<?php
echo idate('d');
?> 

Sample Output:

19

View the example in the browser

See also

PHP Function Reference

Previous: gmstrftime
Next: localtime



PHP: Tips of the Day

PHP: Anonymous recursive PHP functions

In order for it to work, you need to pass $factorial as a reference

$factorial = function( $n ) use ( &$factorial ) {
    if( $n == 1 ) return 1;
    return $factorial( $n - 1 ) * $n;
};
print $factorial( 5 );

Ref : https://bit.ly/38dj7jm