php time

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 :

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

44248