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
https://forums.phpfreaks.com/topic/159378-solved-adding-seconds-minutes-to-a-date/
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 ;)

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.