I’m using jQuery and want to format a date. I don’t want to have to import another plug-in for jQuery. I have found a solution that works in JavaScript i.e.
var now = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
$('##optionButtons').append('<a href="##"class="btn">'
+ curr_date + "-" + curr_month + "-"
+ curr_year + '</a> </ br>');
However, when I add the date shown in the example below I get the following error, why?
var d = value.CREATED;
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
$('##optionButtons').append('<a href="##">'
+ curr_date + "-" + curr_month + "-"
+ curr_year + '</a> </ br>');
ERROR #####################
d.getDate is not a function
###########################
The value of ‘value.CREATED’ is October, 25 2012 00:00:00+0000
I would suggest you to send the date in milliseconds from the server, and then create the date object in javascript as new Date(milliseconds).
See reference here: http://www.w3schools.com/js/js_obj_date.asp
OR
EDIT: Considering your value.created to be a string, I could parse it in the DEMO here.
I hope this would work.