Rename js snippets

This commit is contained in:
Angelos Chalaris
2023-05-19 20:23:47 +03:00
parent 82a614e42e
commit 9d032ce05e
305 changed files with 70 additions and 70 deletions

View File

@ -0,0 +1,21 @@
---
title: Date from Unix timestamp
type: snippet
language: javascript
tags: [date]
cover: number-2
dateModified: 2020-10-15T21:57:17+03:00
---
Creates a `Date` object from a Unix timestamp.
- Convert the timestamp to milliseconds by multiplying with `1000`.
- Use the `Date` constructor to create a new `Date` object.
```js
const fromTimestamp = timestamp => new Date(timestamp * 1000);
```
```js
fromTimestamp(1602162242); // 2020-10-08T13:04:02.000Z
```