PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
tores
Forum Contributor
Posts: 120 Joined: Fri Jun 18, 2004 3:04 am
Post
by tores » Thu Jul 15, 2004 1:39 am
From my mysql-database i fetch these two values:
1. "2004-07-31 23:00:00"
and
2. "02:00:00"
Now I do strtotime on the 1st, and want to add the 2nd. This should result in "2004-08-01 01:00:00"
Anyone know how this could be done in a simple and correct way?
regards tores
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 15, 2004 1:41 am
have you tried strtotime() on the second time?
tores
Forum Contributor
Posts: 120 Joined: Fri Jun 18, 2004 3:04 am
Post
by tores » Thu Jul 15, 2004 1:45 am
yes, but then i get "2004-07-31 23:00:02"...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 15, 2004 1:46 am
you could use explode() and mktime(), or concat the time with "Jan 01, 1969" then strtotime()
tores
Forum Contributor
Posts: 120 Joined: Fri Jun 18, 2004 3:04 am
Post
by tores » Thu Jul 15, 2004 2:03 am
Okey... Now it's almost right. I concatenate so i get
"1970-01-01 02:00:00". When i do strtotime on this i get 3600... But that's the equal of ONE hour, not two... Maybe i have to convert into seconds myself??
tores
Forum Contributor
Posts: 120 Joined: Fri Jun 18, 2004 3:04 am
Post
by tores » Thu Jul 15, 2004 2:22 am
Converted "02:00:00" to secondes using explode... Problem solved