New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fromUnixTime function #830
Comments
The best way to do it right now is to use Math.floor(getTime(new Date()) / 1000) |
@leshakoss what I meant is to create a new Date object from the unix timestamp. I'm currently doing it like |
Oh, my bad. Every function in |
Yep, my situation is I have to initiate the date from epoch time quite a lot in my application, so having the |
👍 helpful to me, |
That's a good idea and easy to implement. My API suggestion is two functions: I'm strictly against being "smart" and trying to guess if it's JS time or Unix time because that would cause unpleasant bugs. Also given that you receive the time in seconds, it's vital to know that JS has time in milliseconds because likely you will send the time back to the back-end. Also, I recommend using ISO-8601 strings for cross-language communications because it does not only save you from this kind of problems but also preserves the original time zone. |
I have already sent a pr for |
@Kingwl oh wow, I did miss it 🤦♂️ Thank you a lot, I'll take a look. |
fromUnixTime
function
PR for this in #937 |
|
I tried to find the function similar to
moment.unix()
where I want to create a date from an unix timestamp in date-fns but couldn't find it. Is it me couldn't find it or it's indeed not exist?The text was updated successfully, but these errors were encountered: