Show HN: An easier way to create and parse Unix Timestamps
stuff.shubhamjain.co
stuff.shubhamjain.co
This is a trivial solution to a trivial problem, but it matters because none of the existing solutions were good enough.
$ date
Fri Dec 16 11:12:17 CET 2016
$ date +%s
1481883140
$ date -d @1234567890
Sat Feb 14 00:31:30 CET 2009
$ date -d 'Sat Feb 14 00:31:30 UTC 2009'
Sat Feb 14 01:31:30 CET 2009
$ date +%s -d 'Sat Feb 14 00:31:30 CET 2009'
1234567890
$ date +%s -d 'Sat Feb 14 00:31:30 UTC 2009'
1234571490We are seriously approaching "println as a service"
How would you go about generating timestamp for a particular date? I guess there isn't any alternative to typing the whole string ( using previous output would save that hassle but why should I have two steps when one is better)? If I have to parse a timestamp for a particular timezone how would I go about it? I am sure there is a nifty option for offset-ing hours but I don't want to hunt down the flag for it.
It's entirely possible to hack _.bashrc_, add some fancy aliases to make the terminal work better but I — and many others — don't consider it worth the arduous effort to create something that would still need terminal window, plenty of keystrokes against what is point-and-click.
the GNU date command is one of many options that honestly should be quicker for most developers.
> It's the same reason why I — and many others — find it convenient to Google "500 pounds in Kgs" in place of GNU Units. Faster, intuitive and fits into my web-development workflow.
I didn't specifically recommend the GNU tool, (and I wouldn't actually recommend that one as the first option anyway), the point was more "whats wrong with a tool you already have on your workstation".
For your example of pounds to kg, Spotlight gives me an answer quicker than any webpage will load, doesn't rely on an internet connection, doesn't show me any ads, nor does it use this information to create a profile that says I might want to either a) buy a calculator or b) go to a BBW dating site.
Back to the dates:
Every computer language in common use and most of the obscure ones handle dates and times. If you're writing code and can't fire up a REPL or use a one-liner to convert a date to timestamp or the reverse, I'd suggest you don't really know that language.
> How would you go about generating timestamp for a particular date? I guess there isn't any alternative to typing the whole string...<snip> plenty of keystrokes against what is point-and-click
I'm not even sure what you're suggesting here... oh. I see.
I refer you back to the first part of this reply then.