fry2010 Posted February 24, 2009 Share Posted February 24, 2009 I have already posted but my post been ignored. All i want to do is generate todays date. Then add 2 weeks to this or 14 days. Then put this into mysql as a correct mysql date, i.e. Y-m-d. Can anyone point me to what I should be looking at? Quote Link to comment https://forums.phpfreaks.com/topic/146771-solved-enter-a-date-into-mysql-2-weeks/ Share on other sites More sharing options...
Darklink Posted February 24, 2009 Share Posted February 24, 2009 $timenow = time() + 1209600; mysql_query("UPDATE tblRow SET date_created='FROM_UNIXTIME({$timenow})' WHERE id=1"); FROM_UNIXTIME() simply converts a timestamp into it's date. And yes... 2 weeks is 1,209,600 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/146771-solved-enter-a-date-into-mysql-2-weeks/#findComment-770655 Share on other sites More sharing options...
fry2010 Posted February 25, 2009 Author Share Posted February 25, 2009 awesome mate, thanks for the reply. I havnt actually tried it yet I have other annoying problems atm, but that is something I havent come across and looks right. Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/146771-solved-enter-a-date-into-mysql-2-weeks/#findComment-770669 Share on other sites More sharing options...
fry2010 Posted February 25, 2009 Author Share Posted February 25, 2009 just another one while your here, say I wanted to then check those dates I put into it, so like : Person registers. expire is set to 2 weeks from now. I check this expiry date when they go to another part of the site, with todays date. Quote Link to comment https://forums.phpfreaks.com/topic/146771-solved-enter-a-date-into-mysql-2-weeks/#findComment-770676 Share on other sites More sharing options...
jitesh Posted February 25, 2009 Share Posted February 25, 2009 check DATE_ADD and INTERVAL in Mysql Quote Link to comment https://forums.phpfreaks.com/topic/146771-solved-enter-a-date-into-mysql-2-weeks/#findComment-770889 Share on other sites More sharing options...
fry2010 Posted February 25, 2009 Author Share Posted February 25, 2009 thanks jitesh, but i have tried using those with INSERT and it doesnt work. It seems the only way to use DATE_ADD and INTERVAL is through a SELECT statement because there is nothing in the docs about INSERTING this information. Not that i can make out anyway. Quote Link to comment https://forums.phpfreaks.com/topic/146771-solved-enter-a-date-into-mysql-2-weeks/#findComment-771198 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.