Problem
I'm trying to format the date from something that looks like 26/05/2015 9:14:46 AM to May 26.
I've managed to get the correct formatting on the current day, which is a good first step. However, in this case, I'm trying to format the date from the previous day, ie. the last time the API was updated regarding river levels var previousDate = result[1].Date;
I've tried var today = new Date(result[1].Date) console logs out 22/05/2015 9:31:19 AM and it returns me "undefined Nan"
scripts.js
$.ajax({
url: 'http://opengov.brandon.ca/OpenDataService/default.aspx?format=jsonp&dataset=riverlevel&columns=Date&callback=?',
type: 'GET',
dataType: 'jsonp',
success: function(result) {
// Dates
var currentDate = result[0].Date;
var previousDate = result[1].Date;
console.log(currentDate, previousDate);
// Change date from DD/MM/YYYY to January 18
// Create a new variable with full month names
var monthNames = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth();
// Puts everything above into a string
var fixedDate = monthNames[mm] + ' ' + dd;
$('.date').html(fixedDate); // This presents the fixed current date
fixedDateseems to be working...it comes out to 'May 26'.var previousDate = result[1].DateWill console log out: 22/05/2015 9:31:19 AMvar previousDate = result[1].DatepreviousDate = 26/05/2015 9:14:46 AMand you'd like to printMay 26?