php time function is used to get current Unix timestamp.
Syntax :
time();
A php function time() returns current Unix timestamp.
A date() function returns current time in the number of seconds with current date.
php time function is used to get current Unix timestamp.
Syntax :
time();
A php function time() returns current Unix timestamp.
A date() function returns current time in the number of seconds with current date.
Example :
<?php
$current_timestamp=time();
echo "<br/>It returns current Timestamp:".$current_timestamp;
$current_date = date("d F Y H:i:s", $current_timestamp);
echo "<br/>It returns Current Date with time:".$current_date;
?>
<?php
//how to get next week time?
$nextweek_time = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60 secs
echo '<br/> Now: '. date('d F Y H:i:s') ;
echo '<br/> Next Week Date Time : '. date('d F Y H:i:s', $nextweek_time ) ."\n";
// Next Week using strtotime(): php function
echo '<br/> Next Week Date Time: '. date('d F Y H:i:s', strtotime('+1 week')) ."\n";
?>
Output :
We explain php time tutorial with example and syntax. You can learn php time web online topic in PHP easily. You can download and print php time tutorial and material in pdf format.
Comments