time

Return current Unix timestamp

Syntax

time(): int

Return

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Examples

1 · void

<?

$return = time();

echo $return;

?>
1674911626

2

<?

$return = time();

$second = 1;
$minute = $second * 60;
$hour = $minute * 60;
$day = $hour * 24;
$week = $day * 7;
$month = $day * 30;
$year = $day * 365;

$format = "Y-m-d H:i:s";

echo date($format, $return) . " now". PHP_EOL;
echo date($format, $return + $second) . " next second" . PHP_EOL;
echo date($format, $return + $minute) . " next minute" . PHP_EOL;
echo date($format, $return + $hour) . " next hour" . PHP_EOL;
echo date($format, $return + $day) . " next day" . PHP_EOL;
echo date($format, $return + $week) . " next week" . PHP_EOL;
echo date($format, $return + $month) . " next month" . PHP_EOL;
echo date($format, $return + $year) . " next year";

?>
2023-01-28 13:13:46 now
2023-01-28 13:13:47 next second
2023-01-28 13:14:46 next minute
2023-01-28 14:13:46 next hour
2023-01-29 13:13:46 next day
2023-02-04 13:13:46 next week
2023-02-27 13:13:46 next month
2024-01-28 13:13:46 next year

checkdate

date

date_add

date_create

date_create_from_format

date_create_immutable

date_create_immutable_from_format

date_date_set

date_default_timezone_get

date_default_timezone_set

date_diff

date_format

date_get_last_errors

date_interval_create_from_date_string

date_interval_format

date_isodate_set

date_modify

date_offset_get

date_parse

date_parse_from_format

date_sub

date_sun_info

date_sunrise

date_sunset

date_time_set

date_timestamp_get

date_timestamp_set

date_timezone_get

date_timezone_set

getdate

gettimeofday

gmdate

gmmktime

gmstrftime

idate

localtime

microtime

mktime

strftime

strptime

strtotime

timezone_abbreviations_list

timezone_identifiers_list

timezone_location_get

timezone_name_from_abbr

timezone_name_get

timezone_offset_get

timezone_open

timezone_transitions_get

timezone_version_get

PHP

Home Menu