jamesxg1 Posted July 27, 2010 Share Posted July 27, 2010 Hiya peeps, I have two rows titled `expiry_date` and `expiry_time` I need to find a way to add 24 hours onto the current time and then insert what date and time that would be. How would I go about this? Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/208998-time-date-24h-help/ Share on other sites More sharing options...
bh Posted July 27, 2010 Share Posted July 27, 2010 Hi, With DATE_ADD function its simple: SELECT DATE_ADD(NOW(), INTERVAL 24 HOUR); DATE_ADD: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add Quote Link to comment https://forums.phpfreaks.com/topic/208998-time-date-24h-help/#findComment-1091655 Share on other sites More sharing options...
aleX_hill Posted July 27, 2010 Share Posted July 27, 2010 If you wanted to get that time and date in PHP you can do: $expiry = time() + (24 * 60 * 60); which will give you the unix timestamp of the expiry time. You can then use date() to split the timestamp into a date and time in whichever format you want. Quote Link to comment https://forums.phpfreaks.com/topic/208998-time-date-24h-help/#findComment-1091676 Share on other sites More sharing options...
jamesxg1 Posted July 27, 2010 Author Share Posted July 27, 2010 If you wanted to get that time and date in PHP you can do: $expiry = time() + (24 * 60 * 60); which will give you the unix timestamp of the expiry time. You can then use date() to split the timestamp into a date and time in whichever format you want. Thanks mate, worked a charm. Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/208998-time-date-24h-help/#findComment-1091687 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.