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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.