timestamp to date
This commit is contained in:
parent
e0aade42ed
commit
f1446881e3
15
content/posts/2023/javascript/timestamp-to-date.md
Normal file
15
content/posts/2023/javascript/timestamp-to-date.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "📅 Преобразовать timestamp в Date на JavaScript"
|
||||
date: 2023-06-11T18:46:36+03:00
|
||||
draft: false
|
||||
tags: [javascript, tips]
|
||||
---
|
||||
|
||||
Необходимо `timestamp` умножить на `1000`,
|
||||
поскольку JavaScript отсчитывает время с момента **epoch** (который равен `01/01/1970`)
|
||||
в миллисекундах, а не в секундах.
|
||||
|
||||
|
||||
```javascript
|
||||
let date = new Date(timestamp * 1000);
|
||||
```
|
Loading…
Reference in New Issue
Block a user