1

Topic: American Time Format

Hey guys,

I was realizing when adding those little touches to my website that I wanted to show time without the ZERO in front of the hour.  An example you may have on your site is 05:16 am, and it looks ugly, well, to me as an American who is use to 5:16 AM.  So the mode is this:

//------------------------------------------
// Get templates
//------------------------------------------
function get_date($date, $format = "date")
{
    global $SESSION;

    $diff = $SESSION->conf['timezone']*60;
    $date = $date - (date("Z") - $diff) + (date("I") ? 3600 : 0);

    if ( $format == "date" ) {
        $format = $SESSION->conf['timeformat'] ? "m/d/Y" : "d/m/Y";
    }
    elseif ( $format == "time" ) {
        $format = $SESSION->conf['timeformat'] ? "h:i a" : "H:i";
    }
    elseif ( $format == "rss" ) {
        $format = "r";
    }
    elseif ( $format == "full" ) {
        $format = $SESSION->conf['timeformat'] ? "m/d/Y g:i A" : "";
    }

    return date($format, $date);
}
// End function


Change h to lowercase g, and lowercase a to A, uppercase.

Simple!

2

Re: American Time Format

And here is my timeformat  extension for "template" approach.

http://www.vldpersonals.com/forum/viewtopic.php?pid=33670#p33670

3

Re: American Time Format

I'm looking into replicating how vldcrowd does it, an example, 58 days ago.

4

Re: American Time Format

maybe this helps you.

get_date($obj->date, "human");

5

Re: American Time Format

whiskeytangofoxtrot wrote:

Hey guys,

I was realizing when adding those little touches to my website that I wanted to show time without the ZERO in front of the hour.  An example you may have on your site is 05:16 am, and it looks ugly, well, to me as an American who is use to 5:16 AM.  So the mode is this:


Change h to lowercase g, and lowercase a to A, uppercase.

Simple!

Nice call. I didn't even bother with that earlier but it certainly refines a site.

And this I will have to try too... great calls

get_date($obj->date, "human");

Last edited by slinky (2009-12-02 09:25:28)

6

Re: American Time Format

mystec wrote:

maybe this helps you.

get_date($obj->date, "human");

That's not the proper way to call it, it's something else.

Also, if you want to display the Day Name, such as Wednesday, today, put lowercase "l" in there, so it will show Wednesday 12/2/2009 3:36 PM

Last edited by whiskeytangofoxtrot (2009-12-02 17:49:02)

7

Re: American Time Format

whiskeytangofoxtrot wrote:
mystec wrote:

maybe this helps you.

get_date($obj->date, "human");

That's not the proper way to call it, it's something else.

Also, if you want to display the Day Name, such as Wednesday, today, put lowercase "l" in there, so it will show Wednesday 12/2/2009 3:36 PM

Good point. I think the day name is quite critical for events. Most people will think of the day of the week and whether they can go (and also place in their calendars.) Thanks for making this point.

8

Re: American Time Format

Ya, I use it and figured throughout that I didn't need the human logging, such as 5 days ago, it's simply better to call it by day name/date/time and the day name works well, because when you have date, sure, you can do the math to figure out the day name in your head, but it's not convenient.  Same with the human output, it's not direct. Well, in my opinion.