Home Menu

time

Return current Unix timestamp

Syntax

time ( void ) : 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

<?

$return = time();

echo $return;

?>
1627500851

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) . PHP_EOL;
echo date($format, $return + $second) . PHP_EOL;
echo date($format, $return + $minute) . PHP_EOL;
echo date($format, $return + $hour) . PHP_EOL;
echo date($format, $return + $day) . PHP_EOL;
echo date($format, $return + $week) . PHP_EOL;
echo date($format, $return + $month) . PHP_EOL;
echo date($format, $return + $year);

?>
2021-07-28 19:34:11
2021-07-28 19:34:12
2021-07-28 19:35:11
2021-07-28 20:34:11
2021-07-29 19:34:11
2021-08-04 19:34:11
2021-08-27 19:34:11
2022-07-28 19:34:11

3

<?

date_default_timezone_set("UTC");
echo time() . " UTC\n";

date_default_timezone_set("America/Los_Angeles");
echo time() . " America/Los_Angeles\n";

date_default_timezone_set("Europe/London");
echo time() . " Europe/London";

?>
1627500851 UTC
1627500851 America/Los_Angeles
1627500851 Europe/London

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms