Hate Posted September 15, 2010 Share Posted September 15, 2010 I need to create some sort of queuing system for my php application to function properly. I was just going to a simple one with a column named "enqueued" and have a queued table that has id, start_time, stop_time. It's more like an ordered "delayed" queue system.. eh whatever. Anyways, what would be the best way to store and access the times in the database? I'm supposing I can just use a TIMESTAMP and have the default value set to TIMESTAMP for the start_time, how how about stop_time I'm assuming still a TIMESTAMP, but with no default value and it can't be null. But, how would I do the time in php? Like adding an amount to a timestamp.. and is there any special functions I can use to read the results from the mysql timestamp fields? Let's say I wanted to take a timestamp of now and add 40 minutes to it.. how do I do this? Quote Link to comment https://forums.phpfreaks.com/topic/213517-time-question/ Share on other sites More sharing options...
aesthetics1 Posted September 15, 2010 Share Posted September 15, 2010 Sounds like this would help you! http://www.gizmola.com/blog/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html Check it out. Very helpful. Quote Link to comment https://forums.phpfreaks.com/topic/213517-time-question/#findComment-1111472 Share on other sites More sharing options...
jcbones Posted September 15, 2010 Share Posted September 15, 2010 I'm not sure I understand what you are asking. I get the first two statements, but the last one kinda fogs my brain. To add an amount to a timestamp in PHP. <?php $timestamp = time(); //or you could set this to any timestamp you want to. echo date('m-d-Y h:i:sa',strtotime('+40 Minutes',$timestamp)); //gives you 40 minutes into the future. ?> To set a timestamp column in MySQL for 40 minutes into the future, you could do. <?php $sql = "UPDATE times SET timestamp_column=DATE_ADD(NOW(),INTERVAL 40 MINUTE) WHERE id='1'"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/213517-time-question/#findComment-1111491 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.