This is what I have in a script that is pulling events with a Google Calendar API:
var datestring2 = (startJSDate.getMonth() + 1) + "/" + startJSDate.getDate();
After I append this to a list it prints out in the format 12/2
while I want it to print out Friday, Dec 2
.
How can I do this? I have looked into date.js
but had no luck.
There is no built in function in Javascript that can do that (I presume you are after something like PHP's
date()
function).You can certainly roll your own solution as other answers have suggested, but unless you are really against it, date.js is great for this.
You can use the libraries
toString()
function to get formatted date strings like so:More information can be found in the DateJS API documention.
This article has some great examples on printing out dates in javacript
And from there you want something like this
Will give you Thursday, December 1st
You need something like: