Re: Military <-> Standard times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd schreef:
> Hi gang:

would you stop calling me that, I'll bet it means something rude in korean. :-P

> What's the slickest way to go from "standard" to military times and back
> again?

wouldn't the slickest way be to carry/store unixtimestamps and
then output whatever version you need when you need it,
the conversion back and forth *seems* pointless.

> 
> Such as:
> 
> 0800 -> 8:00am
> 8:00am -> 0800
> 
> -- or --
> 
> 1600 -> 4:00pm
> 4:00pm -> 1600
> 
> I use the following functions, but is there anything better?
> 
> function standardToMilitary($t)
>    {
>    $t = strftime('%R', strtotime($t));
>    return $t;

what's with the superfluous variable?
why not just:

	return strftime('%R', strtotime($t));

also, small point, if you came across the function
militaryToStandard() somewhere in the code, how would
one know if it were all about about time formats
or elephants?

>    }
> 
> function militaryToStandard($t)
>    {
>    $t = strftime('%r', strtotime($t));
>    return $t;
>    }
> 
> Thanks,
> 
> tedd

PS - I think the best ever name for a Exception class is 'Tantrum':

	throw new Tantrum('Ra Ra Ra Aaaargh');

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux