I'm having trouble extracting the year from my date fields, mostly because it gets reformatted into that weird integer that doesn't look like a date. How do you get this type of integer to look like a date: 1518566400000
I tried using the Date constructor but I don't think I'm using it right (or maybe I can't use it for this purpose at all?). Date | API Reference | ArcGIS API for JavaScript 4.6
My code queries features, and for each feature I want to extract the year from the observation date to put into a select HTML element (drop-down menu). This is the code I have:
function getYears(response){
var features = response.features;
var values = features.map(function(feature){
var obsvDate = feature.attributes.ObsvDate;
return myLegibleDate;
});
return values;
}
I've attempted something as simple as
var obsvDate = new Date(feature.attributes.ObsvDate);
But when I try to print obsvDate to the console -- console.log(obsvDate) -- to see what it looks like, nothing prints. Total javascript newbie so it's possible I'm just doing something stupid.