Subtract Time from string

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

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Subtract Time from string

Post by shiznatix »

Please dont kill me as I couldnt find the answer in searching.

I have 2 strings, say "3:00 AM" and "4:30 PM"

I need to be able to be like: "time worked was 13.5 hours"

is there an easy way to get that 13.5?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

strtotime() may be able to help, but you may end up having to parse or translate the text first (or alternately.)
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

i feared that would be the case. oh well best start now
Post Reply