Jump to content

Quick question about timestamps


tfburges

Recommended Posts

I've done a bit of searching on the net but all that seems to come up is timestamp conversion.  I figure it would be quicker to ask here since the results google gives me vary quite a bit.

 

I'd like to have a timestamp for each time a user submits data through a form.  Should I create a new column in the table and have a hidden input field in the form?  I'm sure there's a simpler command for this out there somewhere.

Link to comment
https://forums.phpfreaks.com/topic/114677-quick-question-about-timestamps/
Share on other sites

Use the time() and date() functions and store it in a column.

 

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

 

http://uk.php.net/time

 

Edit: Use the time function to create a timestamp like 1211287800 and the date function to format the string.

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.