Created
April 16, 2017 16:36
-
-
Save griffiths/08aa60502a287fa3dbb22da65b7a503e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var monthNames = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]; | |
var dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | |
var theDate = new Date(Date.parse(res.query.results.item[i].pubDate)); | |
var todaysDate = new Date(); | |
var thedateCheck = theDate.getTime(); | |
var todaysdateCheck = todaysDate.getTime(); | |
var month = theDate.getMonth(); | |
var dayName = theDate.getDay(); | |
var dayDay = theDate.getDate(); | |
var hours = theDate.getHours(); | |
var mins = theDate.getMinutes(); | |
var ampm = "am"; | |
if (mins < 10) { | |
mins = mins + "0"; | |
} | |
if (hours >= 12) { | |
ampm = "pm"; | |
} | |
if (hours > 12) { | |
hours = hours - 12; | |
} | |
var dateString = dayNames[dayName] + ", " + monthNames[month] + " " + dayDay + ", " + hours + ":" + mins + ampm; | |
if (hours == 12) { | |
dateString = dayNames[dayName] + ", " + monthNames[month] + " " + dayDay + ", Noon"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment