getfullyear
JavaScript Date getFullYear()方法 (JavaScript Date getFullYear() method)
getFullYear() method is a Date's class method and it is used to get the current full year in 4 digits format.
getFullYear()方法是Date的类方法,用于获取4位数字格式的当前全年。
It accepts nothing as the parameter and returns a value between 1000 to 9999.
它不接受任何参数作为参数,并返回1000到9999之间的值。
Syntax:
句法:
var dt = new Date();
dt.getFullYear();
Examples:
例子:
Input:
var dt = new Date();
dt.getFullYear();
Output:
2019
JavaScript code to get the current full year using getFullYear() method
使用getFullYear()方法获取当前全年JavaScript代码
<html>
<head><title>JavaScipt Example</title></head>
<body>
<script>
var dt = new Date(); //Date constructor
var fullyear = dt.getFullYear(); //getting year in 4 digits format
//printing full year
document.write("Year is : " + fullyear);
</script>
</body>
</html>
Output
输出量
Year is : 2019
翻译自: https://www.includehelp.com/code-snippets/date-getFullYear-method-with-example-in-javascript.aspx
getfullyear