Hi everbody,
Once i enter time details in Html form and then click submit button to display add 1 hour to time including seconds.How can i do it by using php code?
Need help Php time coding
Moderator: General Moderators
Re: Need help Php time coding
You need to parse the form input and then add an hour. Look at the DateTime class.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need help Php time coding
With the PHP DateTime class, you can do something like this:
Code: Select all
$datetime = '2016-12-01 12:34:56';
$date = new DateTime("$datetime + 1 hour");
echo $date->format('Y-m-d H:i:s');
(#10850)
Re: Need help Php time coding
Hi,
Thank you for ur reply.Actually, I want to set the time first manually and then display add 1 hour to time after submit the button using html form and php.Could u please give me a code for this one?
Thank you for ur reply.Actually, I want to set the time first manually and then display add 1 hour to time after submit the button using html form and php.Could u please give me a code for this one?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need help Php time coding
I gave you code that you can change a little to do exactly what you want. Just set your date/time.php75 wrote:Hi,
Thank you for ur reply.Actually, I want to set the time first manually and then display add 1 hour to time after submit the button using html form and php.Could u please give me a code for this one?
(#10850)