PHP time – Get current datetime as an integer

The time function is used to obtain the current time from the operating system to second accuracy.

Syntax:

integer time ()

The return value is an integer equal to the seconds since midnight before January 1, 1970.

Example code:

<?php
 
$Now = time();
 
echo 'When this page was loaded, <br>';
echo "$Now seconds had elapsed since January 1, 1970.\n";
 
?>

Output

When this page was loaded,
1261919872 seconds had elapsed since January 1, 1970.

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

 

 
eXTReMe Tracker