Author: https://t.me/ahillary
Channel: https://t.me/semolina_code_python
Chat: https://t.me/python_with_ahillary
YouTube: https://www.youtube.com/@semolinacode
Coding training: https://t.me/how_to_code_web3
Prop trading: https://t.me/semolina_prop
Date
const now: Date = new Date(); // текущая дата и время
const specificDate: Date = new Date("2025-03-18T12:00:00"); // по строке
const fromTimestamp: Date = new Date(1679030400000); // по таймстампу (кол-во мс с 01.01.1970)
// new Date(year, month, date, hours, minutes, seconds, ms)
const fromParams: Date = new Date(2011, 0, 1, 0, 0, 0, 0); // 2010-12-31T21:00:00.000Z
const fromParams2: Date = new Date(2011, 0, 1); // то же самое, так как часы и проч. равны 0
Date
внутри?)Date
хранит один таймстамп — количество миллисекунд, прошедших с полуночи 1 января 1970 года по UTC. Все компоненты (год
, месяц
, часы
) вычисляются при обращении к ним через методы, учитывая локальные и временные зоны.