Jochem Maas wrote:
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.


agree completely, seperate out the display so you have

function militaryTime($t)
{
  return strftime('%R', $t);
}

function standardTime($t)
{
  return strftime('%r', $t);
}

$time = time();
$militaryTime = militaryTime($time);
$standardTime = standardTime($time);

=
but then you could shorten to:

function timeFormat($militaryTime = FALSE) {
  $format = $militaryTime ? '%R' : '%r';
  return strftime($format, $t);
}
$time = time();
$militaryTime = timeFormat(TRUE);
$standardTime = timeFormat();

=
or you could leave you're options open and go for:

function timeFormat($format = '%r') {
  return strftime($format, $t);
}
$time = time();
$militaryTime = timeFormat('%r');

=
or just
$time = time();
$militaryTime = strftime('%r', $time);

:P


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

Reply via email to