Home
> InDesign Scripts > Display day/month name instead of number
Display day/month name instead of number
Sometimes we want to have full day/month name instead of just numbers. Here is really short little snippet to achieve this result. This post also can be found on Adobe’s InDesign scripting forum.
Easiest way is to create prototype for Date. We will first create Arrays of day/month names, and after that we will just return matching name. So, here are the functions:
Day:
Date.prototype.dayName = function() {
var myDay = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
return myDay[this.getDay()];
}
Month:
Date.prototype.monthName = function() {
var myMonth = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
return myMonth[this.getMonth()];
}
Now, how to use this? It’s really simple.
Get current day name:
var myDayName = myToday.dayName();
Or month name:
var myMonthName = myToday.monthName();
Or we can combine it in one long date format like this:
var myCurrentDate = myToday.dayName() + ', ' + myToday.getDate() + ' ' + myToday.monthName() + ', ' + myToday.getFullYear();
That’s it
Simple and effective.
Have fun!
Categories: InDesign Scripts
InDesign CS2, InDesign CS3, InDesign CS4, InDesign CS5
Comments (0)
Trackbacks (0)
Leave a comment
Trackback
IndiSnip on Twitter!
IndiSnip on Facebook!
Contact IndiSnip by e-mail!
