Traditional Culture Encyclopedia - Almanac inquiry - How does Js manipulate date objects?
How does Js manipulate date objects?
1 . new Date(); ? This is also necessary if time is used.
2 . get full year(); Get the current year
3 . getmonth(); Get the current month? But the month is calculated from 0- 1 1, so the obtained month needs+1.
4 . get hours(); Get the current hour
5 . getdate(); Get the current date
6 . get minutes(); Get the current minute
7 . get seconds(); Get the current second
8 . gettime(); Get the current millisecond value
9 . tolocalestring(); Gets the local time format string
10 . getday(); Get the current week? Sunday is the first day abroad, so Sunday is 0? Other 1-6 one-to-one correspondence.
& lt script? type = " text/JavaScript " & gt;
//Date object
/*? 1.new? Date ()? Get the current time
2.getFullYear()? Acquisition year
3.getMonth()? Get the month 1 as 0? The actual month is greater than the displayed month 1.
4.getHours()? acquisition time
5.getDate()? Get the date
6.getMinutes()? Get meeting minutes
7.getSeconds()? Acquisition second
8.getTime()? Get millisecond value
9.toLocaleString()? Gets the local time format string
10.getDay()? Get a foreign Sunday as the first day? So Sunday is 0 and Saturday is 6, which just corresponds to */
var? Dating? =? New? date(); //An empty parameter structure displays the current time.
Alarm (date);
alert(date . get full year());
alert(date . getmonth()); //When counting? From 0 to 1 1 calculation.
alert(date . get hours());
alert(date . getdate());
alert(date . get minutes());
alert(date . get seconds());
alert(date . gettime());
alert(date . tolocalestring());
alert(date . getday()); //Number of weeks abroad 0-6? Sunday is the first day? So Sunday is 0, and others correspond to 1-6.
var? Date 2? =? New? Date (/kloc-0 1000000000000);; //You can add parameters in it. This parameter is the starting year and month in milliseconds, that is, 0970 1 month 1 day at 65438+GMT.
alert(date 2 . tolocalestring());
& lt/script & gt;
- Related articles
- The ancient yellow calendar has been auspicious for thousands of years.
- When is the best time to fish?
- View the logs in the old yellow calendar
- Is February 2023 16 suitable for having children? February 2023 16, how about having a baby?
- [auspicious day of the zodiac] 202 1 year 1 month 19 calendar query?
- Full moon wine invitation letter
- How about cooking all day?
- 20 19 12.30 Gregorian calendar query
- Is May 16, 2023 an auspicious day for the zodiac?
- The story of Oracle Bone Inscriptions.