JQuery to Get Current Day Month and Year in Asp.Net C# VB.Net

Date Time is one of the mostly used information in any web page. Most of the times we need to know the Current Day in number, Current month name & Current Year. Here in this article I will show you how we can achieve Current Day, Current Month name & Current Year from client side using JQuery. To do that we will use getDate() method to get the Current Day in Number, getMonth() method to get the Current Month in number & getFullYear() to get the four digit Year.

JQuery to Get current Day Month and Year - Asp.Net Csharp VB.Net

JQuery Code Example to Get Current Day Month and Year:

<script type="text/javascript">
    $(document).ready(function () {
        var current_Day = (new Date).getDate();
        var current_Month = (new Date).getMonth() + 1;
        var current_Year = (new Date).getFullYear();

        var month_List = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
        current_Month = month_List[current_Month - 1];

        alert("Current Day: " + current_Day + " Current Month: " + current_Month + " CurrentYear: " + current_Year);

Note: We did not get Month Name directly from JQuery function. getMonth() method return the array index number that’s why we need to add or subtract 1.

Download Code Example C#        Download Code Example VB.Net

Posted in .Net, Asp.net, C#, Client, JQuery, VB.Net

Leave a Reply

Your email address will not be published. Required fields are marked *