News for hackers. Stuff that matters.
Re:Show HN: An easy way to convert time by schoen on Thursday June 29, 2017 @03:38PM (#14666233)
I can see that this might be useful for interactive human use, but I'm not sure of the benefit of the API. Most popular programming languages have a library to do this already without relying on a network service.

Unix command line with GNU date:

date --iso-8601=seconds

date --iso-8601=seconds -u # UTC

date --iso-8601=seconds -d @1234567890 # specified time stamp

date -d 2017-06-29T12:28:57-07:00 +%s # other direction

Python: https://stackoverflow.com/questions/2150739/iso-time-iso-860...

Using a network API for this kind of conversion function that's already built into programming languages reminds me of the left-pad controversy. You don't need to outsource basic programming tasks to third-party libraries, and you also don't need to outsource them to third-party network services.

Re:Show HN: An easy way to convert time by avg_dev on Thursday June 29, 2017 @03:44PM (#14666280)
I don't think of it as an API to integrate into your service, but more of an easy to remember thing like http://http.cat/503 http://http.cat/404 etc.
Re:Show HN: An easy way to convert time by jrimbault on Thursday June 29, 2017 @04:44PM (#14666714)
How does this exist ? I like it.
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @04:54PM (#14666783)
Creator here.

The API is definitely not useful for most programmatic things. Just a simple way to get the time if you don't have the ability to use bash or a programming language.

I mostly wanted a way to copy a timestamp and type in a url to get a human readable time in local time. (https://epoch.sh/1498769628)

Re:Show HN: An easy way to convert time by sprt on Thursday June 29, 2017 @04:48PM (#14666738)
Over the years, I've noticed the best way to learn about shell one-liners is to read HN comments on programs that implement trivial functionality.
Re:Show HN: An easy way to convert time by diggan on Thursday June 29, 2017 @03:50PM (#14666322)
> but I'm not sure of the benefit of the API

I agree, when talking about programming language, but maybe could be useful when using services like Zapier and similar, when you don't want to use a programming language for doing simple things or don't know programming.

Re:Show HN: An easy way to convert time by z3t4 on Thursday June 29, 2017 @05:14PM (#14666910)
back in school we was tasked to write something, i dont recall what it was but it was mostly facts. i found a good paper on the internet and while rewriting it i thought to my self, why am i rewriting it? it was already written exactly as i would put it, and the facts where right. so i gave the paper i found on the internet to the teacher. but so did also one of my class mates. thats how it feels like when reusing someone elses code. it feels like cheating.
Re:Show HN: An easy way to convert time by ldenneau on Thursday June 29, 2017 @05:42PM (#14667109)
Does not handle leap seconds:

https://api.epoch.sh/2016-12-31T23:59:60Z

Edge case, but 2016-12-31T23:59:60Z is a valid UTC time.

Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @06:21PM (#14667332)
I didn't even know that was possible...
Re:Show HN: An easy way to convert time by Klathmon on Thursday June 29, 2017 @06:23PM (#14667339)
Welcome to the rabbit hole that is date/time handling.
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @06:41PM (#14667439)
Yup. Probably just step lightly out of that one. Already have too many irons in the fire
Re:Show HN: An easy way to convert time by justbaker on Thursday June 29, 2017 @06:57PM (#14667512)
Here there is no time...
Re:Show HN: An easy way to convert time by TazeTSchnitzel on Thursday June 29, 2017 @06:58PM (#14667516)
Is this using a proper date/time library underneath, or did you write it yourself?
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @07:25PM (#14667633)
moment.js mostly
Re:Show HN: An easy way to convert time by nategri on Thursday June 29, 2017 @07:53PM (#14667763)
Um
Re:Show HN: An easy way to convert time by pcunite on Thursday June 29, 2017 @03:15PM (#14666087)
I've been using epochconverter.com for several years. Thank you for the effort. I like to break things. So, don't worry about this. But, it will not process 10413795600?
Re:Show HN: An easy way to convert time by thieving_magpie on Thursday June 29, 2017 @04:54PM (#14666786)
It looks like the max value is 9999999999.

"unix": 9999999999, "utc": "2286-11-20T17:46:39Z"

edit: No, I was very wrong. Adding another 9 seems to work. However, moving up one to 10000000000 does not.

edit2: Okay I wasn't wrong. It just was changed by the OP very quickly. Which I guess makes this entire post wrong now. But let the record reflect for a very brief period in my life I was correct.

Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @05:01PM (#14666843)
Yup, good catch.
Re:Show HN: An easy way to convert time by stephengillie on Thursday June 29, 2017 @03:40PM (#14666247)
January 1, 2300 1:00 AM? What's the significance of that date?

In Powershell, it's a one-liner.

  PS C:\> (Get-Date 1/1/1970).addSeconds(10413795600)
  
  Monday, January 01, 2300 1:00:00 AM
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @04:56PM (#14666812)
Wow... thanks for that. I had a silly check for length of unix time stamp (so it can handle things like Date.now())

Should be fixed now

Re:Show HN: An easy way to convert time by mixmastamyk on Thursday June 29, 2017 @05:09PM (#14666887)
Fun, but I found this part interesting:

    ⏵ http https://api.epoch.sh/ 
    HTTP/1.1 200 OK
    ...
    Date: Thu, 29 Jun 2017 21:06:20 GMT
    ...
    
    {
        "utc": "2017-06-29T21:06:19Z"
    }

One second off. ;)
Re:Show HN: An easy way to convert time by eyelidlessness on Thursday June 29, 2017 @03:39PM (#14666238)
It's not clear how it detects which type you've passed, but this is pretty unexpected:

https://api.epoch.sh/-100

`{"local":"0099-12-31T16:00:00-08:00","unix":-59011459200,"utc":"0100-01-01T00:00:00Z"}`

This too:

https://api.epoch.sh/8675309

`{"local":"8675-11-04T16:00:00-08:00","unix":211615977600,"utc":"8675-11-05T00:00:00Z"}`

Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @05:29PM (#14666993)
This should be fixed now. As others pointed out, had some bad validation
Re:Show HN: An easy way to convert time by eyelidlessness on Thursday June 29, 2017 @05:29PM (#14666999)
Why is `-100` invalid?
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @05:55PM (#14667172)
You know, I have no idea why I even checked for < 0 since it's seconds backwards since epoch. Just a mental snag I guess
Re:Show HN: An easy way to convert time by dkharrat on Thursday June 29, 2017 @04:05PM (#14666438)
It would also be useful to provide a way to convert the other way around (from a date to epoch).

I actually built a similar tool a while ago: http://timeconv.io/ that's similar to yours :) The goal is to provide a set of useful time/date utilities.

Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @04:57PM (#14666816)
Re:Show HN: An easy way to convert time by avg_dev on Thursday June 29, 2017 @03:37PM (#14666225)
Neat site. How does it know my local time?
Re:Show HN: An easy way to convert time by leovander on Thursday June 29, 2017 @04:36PM (#14666659)
Looking at the response headers, could they be inferring the timezone based on what cloud front server the user hits?

Edit: This is probably way over thinking it, but here are the Amazon data center IP's. Search "CLOUDFRONT" https://ip-ranges.amazonaws.com/ip-ranges.json to see the list of regions.

Re:Show HN: An easy way to convert time by Falling3 on Thursday June 29, 2017 @04:37PM (#14666670)
IP geolocation - try it from a proxy.
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @04:58PM (#14666828)
Geo lookup on your IP to get a time zone. Easy to spoof with a proxy / vpn.
Re:Show HN: An easy way to convert time by edpichler on Thursday June 29, 2017 @03:48PM (#14666309)
Getting of your browser?
Re:Show HN: An easy way to convert time by avg_dev on Thursday June 29, 2017 @03:52PM (#14666340)
Yes - but how? I looked at the HTTP headers I was sending and none of them contained the time zone.
Re:Show HN: An easy way to convert time by hakanito on Thursday June 29, 2017 @04:01PM (#14666400)
Open your console and type `new Date()`. In JS every date is local time by default
Re:Show HN: An easy way to convert time by avg_dev on Thursday June 29, 2017 @04:02PM (#14666408)
Sure, but there is no JS on the page, and curling https://api.epoch.sh gives the same result.
Re:Show HN: An easy way to convert time by secstate on Thursday June 29, 2017 @04:07PM (#14666456)
IP sniffing?
Re:Show HN: An easy way to convert time by jaytaylor on Thursday June 29, 2017 @07:06PM (#14667548)
@Prefinem Do you plan to release the site source code?

I like it, a cool and useful project for sure.

Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @08:49PM (#14667955)
I could. It’s just a simple Lambda function.

I will try and do so tomorrow.

Re:Show HN: An easy way to convert time by dwrowe on Thursday June 29, 2017 @03:44PM (#14666281)
Doesn't seem to like any Unix timestamps less than 10 characters long?
Re:Show HN: An easy way to convert time by Prefinem on Thursday June 29, 2017 @04:58PM (#14666823)
Fixed. Silly me