Link to home
Start Free TrialLog in
Avatar of djinnrutger
djinnrutger

asked on

PHP date/time function formating

I am building a web site to track the amount of time spent on a project. basicly it has a form that when i click the submit button it records the time into a sql database as a start time, then the next click as a stop time. I am doing this in PHP and MYSQL. when it records the data, it is the number of seconds since jan 1 1970 useing the time() function.

I created a report to list the times and i use the format print date("g:i:s a", $items["start"]) and that give me the time it was recorded. and then at the end of the report i have it total up the records and i get the total seconds useing the function print date("h:i:s",$total). again it works but my hours are always set at 6. I am guessing that this is because of the time zone differance. i am in CST. is there a work around for this? or is there a better way to handle this?

Thanks!
Avatar of hernst42
hernst42
Flag of Germany image

try gmdate http://www.php.net/gmdate

Or write you own function to print out the seconds. Guess information will also be lost if the total exceeds 24h which will start from 0 again.
ASKER CERTIFIED SOLUTION
Avatar of jeffreydn
jeffreydn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djinnrutger
djinnrutger

ASKER

Worked Perfect!