PHP - Function time()


Advertisements


Syntax

int time ( void );

Definition and Usage

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

Parameters

Parameter Description
void NA

Return Value

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

Example

Following is the usage of this function −

<?php
   // 7 days; 24 hours; 60 mins; 60secs
   $nextWeek = time() + (7 * 24 * 60 * 60);
   
   echo 'Now:       '. date('Y-m-d') ."\n";
   echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
?>

This will produce the following result −

Now:       2005-03-30
Next Week: 2005-04-06

php_function_reference.htm

Advertisements