Jump to content

[SOLVED] adding seconds / minutes to a date


Yeodan

Recommended Posts

what's the easiest way to do this?

 

in one spot I need to add 20 seconds to the current time

in another spot I need to add 2 minutes to the current time

 

the easiest method seems to be

date() + 20

but I'm not sure wether that'll work, probably not

 

$date = mktime(date("H"), date("i"), date("s") + 20, date("m"), date("d"), date("y");

I need to compare $date to a mysql timestamp, so I'm not sure wich format to use or even wether I should use a timestamp in my mysql database or some other format there too

 

the purpose of the function is to check wether the date + added time has already passed or not, so I need a full date, not just the time

Link to comment
Share on other sites

Heres an easy options

pull the datetime out a unix (same format as time())

SELECT myDate, UNIX_TIMESTAMP(myDate) as myUnixDate FROM table etc etc

your see that myDate is 2009-05-23 14:27:57 

but myUnixDate is 1243085277

 

so you can still you the + 20 etc ;)

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.