Forum Moderators: coopster

Message Too Old, No Replies

Now()

formats for displaying time.

         

capulet_x

3:10 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



When I create a query like:

UPDATE time SET watch = NOW()

I get a result like :

1176673403

What I was wondering is what is the above method of formating time called?
I've been trying to research the method used to get time results such as the format above because I would like to know the method of converting it back to a standard more conventional format like:

14:32:00

I know how to format time as I put it in the database but if there a function to convert the format from one display method to another?

capulet_x

3:17 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



Okay, I did a little more reading and found that this is a UNIX timestamp. So now I just need find out how it's created so that I can make a script to convert it.

mooger35

3:24 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



use date [ca.php.net]

I think this is right:
$today = date('H:i:s',strtotime("now"));

edit: sorry I had the wrong time format for you.

capulet_x

3:43 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



mooger35,

Thanks for your input. Is there a function to calculate total time between two time stamps? Lets say I had a button page A and I wanted to calculate how long it took a visitor to get from page A to page B but I only want the result in 00:00:00 format. Overall what I'm trying to do is vonvert the Unix timestamp to a standard GMT format so that I can get the difference between two time events.

whoisgregg

4:44 pm on Apr 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The date [php.net] function expects a UNIX timestamp, so calling strtotime on a unix timestamp is unnecessary and will result in screwed up output.

To check the difference between two timestamps, just find the difference (

$diff = abs($time1-$time2);
) then break it apart into constituent time blocks. This past thread [webmasterworld.com] gives an idea of the process and the PHP manual page for the time function [php.net] has some good examples in the comments.

mooger35

4:59 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



Oops... don't know what I was thinking there. Got caught up in the "now"

$now = date('H:i:s');