Monday 26 August 2013

PHP Function time()

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).

Paramters

ParameterDescription
voidNA

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 following result:
Now:       2005-03-30
Next Week: 2005-04-06

No comments:

Post a Comment