Jump to content

Date conversion using gettimeofday


SCook

Recommended Posts

Sure, use the strtotime() function:

 

<?php
echo strtotime("1/4/2008 00:00:00");
?>

 

Note, the strtotime function works with the American m/d/y format - not the uk d/m/y format. Don't know where you're from, so i don't know if that's an issue or not.

The gettimeofday() returns the number of seconds since the unix epoch as part of the returned array:

<?php
$tod = gettimeofday();
echo $tod['sec'];
?>

 

Use the strtotime() function to get the number of seconds for an arbitrary date:

<?php
echo strtotime('1/4/2008 12:00 am');
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.