Hi I was wondering if there is any jquery function around which can take this dateTime "2010-10-18 10:06" and convert and split it returning "2010/10/18" and "10:06".
It would be also nice if the same function could either receive "2010-10-18 10:06" or "2010-10-18" only and return as mentioned above, or different formats besides "2010/10/18" like 18-10-2010" or and 18th of October 2010, giving the option but not that important, just curious about jQuery power dealing with dates.
Thanks.
$('#date'). on('change', function() { var new_val = $(this). val(). split('-'), dateYear = parseInt(new_val[0]), dateMonth = parseInt(new_val[1]), dateDay = parseInt(new_val[2]); $('<input>', { type: 'hidden', name: 'date_day', id: 'date_day', value: dateDay }).
You can do it like that: var d = new Date(); var month = d. getMonth()+1; var day = d. getDate(); var output = d.
In ISO 8601, T is a delimiter used for time, and Z is added to the end to indicate that the date has a zero UTC offset.
Converting with DateJs should be as easy as:
var d1 = Date.parse('2010-10-18, 10:06 AM');
alert(d1.toString('dd/mm/yyyy HH:mm:ss GMT'));
It's currently the best library around
Without a any external jQuery plugin like DateJs. We can get the date as given below.
var datetime= '2010-10-18 10:06 AM' // Default datetime will be like this.
//By Spliting the input control value with space
var date=datetime.split(' ')[0];
//date -2010-10-18
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With