This is the date string I'm working with: 2017-04-18 04:49:06
I'm writing a script that needs to get the hours to a variable, change it and then replace the new hour value with the old one.
Asked
Active
Viewed 29 times
0

Michael
- 109
- 1
- 1
- 13
-
Can you post what you have tried so far? – Jerodev Aug 16 '17 at 12:28
-
1`date("H", strtotime("2017-04-18 04:49:06"));` – Andreas Aug 16 '17 at 12:28
-
Use the [`DateTime`](http://php.net/manual/en/class.datetime.php) class to handle dates in PHP. It allows you to change the components (set date and/or time, add/subtract time intervals) then format it again as string. – axiac Aug 16 '17 at 12:31