Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Why on earth do you then have to invent a new syntax for time formats that requires you to memorize a “magic” timestamp, and try to remember if it follows the broken US practice of illogical month/day ordering.

I find this kind of critizism to be unfounded as it seems the author have not actually used the feature but is just complaining about it.

This is how it is used, and as you see there is no preference for "the broken US practice of illogical month/day ordering":

    n := time.Now()
    localTimeFormat := "2006-01-02 15:04:05"
    formatted := n.Format(localTimeFormat)


The point is that in order to remember the order that the dates should be put in, you need to remember google's 'reference' layout .. Jan 2 15:04:05 2006 MST ... in other words:

1) Month, 2) Day of Month, 3) Hour, 4) Minute, 5) Second, 6) Year

So yes, you DO need to remember that the numbers are 'month/day' ordered, in order to, from memory, derive that it's 2006-01-02, and not 2006-02-01. With strftime, we effectively standardised "%Y-%m-%d"


> google's 'reference' layout

Nothing to do with Google here, by the way. It's just the default format of the Unix date command.

So if you can't remember the order, just switch to your shell and run `LC_ALL=C date`.


Not quite. With date, the timezone comes before the year.

LC_ALL=C date => Sun Feb 13 14:27:18 GMT 2022




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: