Home > Web Front-end > JS Tutorial > Tutorial on how to use the getYear() method to manipulate time in JavaScript_Basic knowledge

Tutorial on how to use the getYear() method to manipulate time in JavaScript_Basic knowledge

WBOY
Release: 2016-05-16 15:55:47
Original
1651 people have browsed it

The javascript Date.getYear() method returns the year on the specified date according to universal time. getYear is no longer used and has been replaced by the getFullYear method.

The value returned by getYear is the current year minus 1900 (in JavaScript 1.2) and the returned year is either a 2 or 4 digit year, for example, if the year is 2026, the returned value is 2026 so test this Before function, please make sure the JavaScript version.
Grammar

Date.getYear()

Copy after login

Here are the details of the parameters:

  • NA

Return value:

Returns the year of the specified date according to universal time.
Example:

<html>
<head>
<title>JavaScript getYear Method</title>
</head>
<body>
<script type="text/javascript">
  var dt = new Date();
  document.write("getYear() : " + dt.getYear() ); 
</script>
</body>
</html>

Copy after login

This will produce the following results for 2012:

getYear() : 212

Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template