Untitled
unknown
plain_text
a year ago
618 B
39
Indexable
const currentDate = new Date(); const year = currentDate.getFullYear().toString().padStart(4, '0'); const month = (currentDate.getMonth() + 1).toString().padStart(2, '0'); // Month is zero-indexed const day = currentDate.getDate().toString().padStart(2, '0'); const hours = currentDate.getHours().toString().padStart(2, '0'); const minutes = currentDate.getMinutes().toString().padStart(2, '0'); const seconds = currentDate.getSeconds().toString().padStart(2, '0'); const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; console.log(formattedDate); // Output: '2022-03-25 00:00:00'
Editor is loading...
Leave a Comment