Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get month from datepicker texbox actually I am using format dd-mm-yyyy

Iam using below code its getting day but i need month plaese help out from this

thanks in advance

var d = new Date($("#txtInvMgmtFromDate").val());

var month=d.getMonth();

What I have tried:

var d = new Date($("#txtInvMgmtFromDate").val());

var month=d.getMonth();
Posted
Updated 8-Mar-16 4:29am

1 solution

var d = new Date($("#txtInvMgmtFromDate").val().replace( /(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3") );
var month = d.getMonth();


or

JavaScript
var dparts = $("txtInvMgmtFromDate").val().split("-");
var d = new Date(from[2], from[1] - 1, from[0]);
var month = d.getMonth();
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900