Jump to content

Quick easy date question.


pocobueno1388

Recommended Posts

I am trying to add the current date + 7 days to the database whenever a user clicks a submit button, why won't this work?

[code]
$next_breed = date ('Y/m/d', strtotime ("U +7 days"));

mysql_query("UPDATE dog SET last_bred='$next_bred' WHERE dogID='$row3[dogID]'");
[/code]

It does absolutely nothing to the 0000-00-00 date in the database.
Link to comment
Share on other sites

So long as when you want to use MySQL's date/time functions you don't mind the additiona overhead of always converting it with FROM_UNIXTIME() first. e.g.
[code]
SELECT DATE_FORMAT(FROM_UNIXTIME(newtime), '%m-%d-%Y %H:%i') FROM tablename
[/code]

And you can always tell any users who might be executing their own SQL queries on the database that, with experience, they will soon get to recognise 1157137200 as  '2006-09-01 20:00' without any problem at all.
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.