Page 1 of 1
Converting Time
Posted: Wed Sep 03, 2003 5:58 pm
by JPlush76
hey all,
lets say I have a time: 3:31 PM
just like that...
how do I convert that into a usable time so I can do time differences on?
for example I have IN TIME: 3:31 PM OUT TIME: 12:54 AM
I'd want to convert those into usable time stamps so I can say the difference between your in and out time is XX hours XX minutes
anyone do anything like that before?
thanks

Posted: Wed Sep 03, 2003 6:00 pm
by qads
i once tried, forgot what i did but it didn't work lol....is that any help?

LOL
but yea...i'd like to know too please

Posted: Wed Sep 03, 2003 6:01 pm
by JPlush76
thanks Qads! lol
Posted: Wed Sep 03, 2003 6:01 pm
by qads
that was quick lol
Posted: Wed Sep 03, 2003 8:08 pm
by volka
strtotime might help.
But without a date
Code: Select all
<?php
$sIn = '3:31 PM';
$sOut = '12:54 AM';
$nIn = strtotime($sIn);
$nOut = strtotime($sOut);
echo date('F j, Y, g:i a', $nIn), "\n", date('F j, Y, g:i a', $nOut);
?>
it will get confused. On the other hand
Code: Select all
<?php
$sIn = '9/4/2003 3:31 PM';
$sOut = '9/3/2003 12:54 AM';
$nIn = strtotime($sIn);
$nOut = strtotime($sOut);
echo date('F j, Y, g:i a', $nIn), "\n", date('F j, Y, g:i a', $nOut);
?>
works.
$nIn and $nOut are number of seconds since the unix epoch representing the two datetimes, so you might subtract $nIn from $nOut.
Posted: Wed Sep 03, 2003 8:10 pm
by JAM
hehe
Perhaps the following can give some more ideas?
Code: Select all
<pre>
<?php
$in = '3:31 PM';
$out = '12:54 AM';
echo strtotime($in)."\n";
echo strtotime($out)."\n";
?>
Posted: Wed Sep 03, 2003 8:11 pm
by JAM
Gah!

Posted: Wed Sep 03, 2003 8:19 pm
by volka
It's special mod that posts a previously stored reply the moment someone else presses the "post reply" button
just kidding
Posted: Wed Sep 03, 2003 8:25 pm
by JAM
Hahaha
You have a new message!
Do you want to overwrite the users responce with your own? Select from:
a) As is...
b) Rewrite slightly...
c) You own code, in your own words...