Buradasın
JavaScript Date Components Guide
bobbyhadz.com/blog/javascript-get-year-month-day-from-dateYapay zekadan makale özeti
- Basic Date Components
- Date.getFullYear() returns a four-digit year number
- Date.getMonth() returns an integer from 0 (January) to 11 (December)
- Date.getDate() returns an integer between 1 and 31
- Months are zero-based in JavaScript, January is 0
- Timestamp Components
- Timestamps can be converted to Date objects using Date() constructor
- Timestamp components can be converted to local time using getFullYear()
- Timestamp components can be converted to UTC using getUTC* methods
- Formatting and Usage
- Month and day values less than 10 are single digits
- String.padStart() can be used to pad month and day to two digits
- Date objects can be used to get current year, month, and day
- Functions can be created for reusable date component functions