Skip to content Skip to sidebar Skip to footer

How To Add Date Time Value To Input By Onclick Checked Jquery

i have this

Solution 1:

jsFiddle Demo

var months = newArray(12);
months[0] = "Jan";
months[1] = "Feb";
months[2] = "Mar";
months[3] = "Apr";
months[4] = "May";
months[5] = "Jun";
months[6] = "Jul";
months[7] = "Aug";
months[8] = "Sep";
months[9] = "Oct";
months[10] = "Nov";
months[11] = "Dec";

var d = newDate;
var amOrPm = d.getHours() >= 12 ? "PM" : "AM";

var x = months[d.getMonth("mmm")] + " " + d.getDate() + ", " + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + " " + amOrPm;
jQuery('.hidden-input').val(x);

EDIT - I added the hh:mm:ss AM/PM too.

Post a Comment for "How To Add Date Time Value To Input By Onclick Checked Jquery"