Moment JS Get Year from Date Example

By Hardik Savani January 18, 2021 Category : jQuery

This simple article demonstrates of moment js get year from date. i explained simply step by step moment js get year from date. let’s 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').

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');







I hope it can help you...

Tags :