I am trying to format a date in js with “mmdd” format as the final result.
If I set var s = "" i reach my alert, but if i do not, the code does not run.
any pointers would be appreciated!
function stateChange(e){
var p = (document.getElementById("stateSelect").value);
var t = new Date();
var s = t.format("mmdd");
alert(s);
}
There is no function format for a date in javascript.
Below is a link to a page with 10 different ways to format dates in javascript:
http://www.webdevelopersnotes.com/tips/html/10_ways_to_format_time_and_date_using_javascript.php3
EDIT
The below also looks promising to use to get what you’re after:
http://www.datejs.com/