urbandsigns.com Posted August 9, 2006 Share Posted August 9, 2006 I have time (no date) in the format: 00:00:00 and I need to add a few seconds to it, how do I do this? Quote Link to comment https://forums.phpfreaks.com/topic/17035-need-help-adding-seconds-to-time/ Share on other sites More sharing options...
Daniel0 Posted August 9, 2006 Share Posted August 9, 2006 Is this what you're looking for: [code]<?php$time = '13:15:07';echo "Time: {$time}<br />"; $new_time = date('H:i:s',strtotime($time)+8); // adds 8 secondsecho "New time: {$new_time}";?>[/code]It would generate the output: [code]Time: 13:15:07New time: 13:15:15[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17035-need-help-adding-seconds-to-time/#findComment-71903 Share on other sites More sharing options...
urbandsigns.com Posted August 9, 2006 Author Share Posted August 9, 2006 Thanks for the response, but this isn't adding correctly. Here is my code based on what you posted:[code]$total2 = date('H:i:s',strtotime($_GET["score"])+$_GET["cones"]);[/code]Scores: 00:33:26Cones: 39Total2: 00:34:05 Quote Link to comment https://forums.phpfreaks.com/topic/17035-need-help-adding-seconds-to-time/#findComment-71913 Share on other sites More sharing options...
urbandsigns.com Posted August 9, 2006 Author Share Posted August 9, 2006 Nevermind, just realized the the last number is seconds and not milliseconds. It is working correctly. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/17035-need-help-adding-seconds-to-time/#findComment-71919 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.