Jump to content

[SOLVED] php timestamp


jonaHill87

Recommended Posts

Hi. Just wondering how I can create a timestamp using php. I need two timestamps, one with todays date/time and another with a week from todays date/time. Then I need to stick them into 2 fields in mysql. Can anyone help me out?

I dont need a big long code, I just need the timestamps and maybe a hint of how to chuck them into the fields using an INSERT mysql command and what datatypes for the fields I should be using. Thanks to anyone who helps.

Link to comment
https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/
Share on other sites

I prefer to use an INT field to store the dates, so we can store them as a unix timestamp.

 

<?php
$now = time();
$next_week = strtotime('next week');
mysql_query("INSERT INTO tbl SET col1 = $now and col2 = $next_week") or die(mysql_error());
?>

 

You can then format the dates however you would like when you output them, using the date() function.

Link to comment
https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/#findComment-433991
Share on other sites

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.