I am pulling a row from a mysql database which has a time stamp, like this: 2010-10-10 16:56:23
I need to compare this time stamp to the current time from the date object, and see if 30 minutes has passed.
thanks!
I am pulling a row from a mysql database which has a time stamp, like this: 2010-10-10 16:56:23
I need to compare this time stamp to the current time from the date object, and see if 30 minutes has passed.
thanks!
2010-10-10 16:56:23
make it 20101010165623
get current time also in this format
Just compare bot as integer itself.
You got it!.
Or
mysql have datediff() function which will help you.
http://www.w3schools.com/SQl/func_datediff_mysql.asp
in the example , your case second paramtere will be now()
How about:
(new Date() - Date.parse('2010-10-10 16:56:23')) >= 1000 * 60 * 30 // (current date - date) >= 30 minutes
I'm not sure about the whole time zone thing though.. if the timezones between the server and user are different you may need to mess around with that.
Use DATE_ADD function and cast date type to your string
NOW() > DATE_ADD(CAST('2010-10-10 16:56:23' AS date), INTERVAL 30 MINUTE)
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast