Moment JS Get Year from Date Example

Admin   Jquery   106  2021-03-13 05:00:06

Hi Dev,

Now let's see example of moment js get year from date. we will show moment js get year from date. we will discuss about get year from date moment jquery. i explained simply about jquery moment get year from date. Here, Creating a basic example of how to get year from date in moment js.

Here, i will give you simple example of jquery moment js get year from date using format('YYYY').

So let's see both example with output:



<!DOCTYPE html>



<title>Jquery Moment Example -</title>

<script src="" crossorigin="anonymous"></script>

<script src="" crossorigin="anonymous"></script>



<h1>Jquery Moment Example -</h1>


<script type="text/javascript">

var oneDate = moment('02-01-2021', 'DD-MM-YYYY');

var yearName = oneDate.format('YYYY');


var oneDate = moment();

var yearName = oneDate.format('YY');








It will help you....