Reputation: 329
I've come across a problem I've not been able to solve. I have a log which regularly needs updating with today's date in a specific format. I've attempted to write a script to do so but essentially what I would like is to assign a keyboard shortcut, but going into a menu would be acceptable. What I need is today's date in the format
### Tuesday - 16/01/2018
The script I've got currently includes the line
var currentDate = Utilities.formatDate(new Date(), "GMT", "### - dd/MM/yyyy");
This gets me almost everything I need, but after the #s I'd like the day of the week. I can see a few functions that apply to sheets, that work there, but how would I get this working in docs?
And assuming I manage that this is currently assigned to a custom UI menu, is it also possible to hook this up to a macro/keyboard shortcut?
Thanks!
Upvotes: 2
Views: 10578
Reputation: 8736
You need to change format slightly and use EEEE
which will print day of a week:
var currentDate = Utilities.formatDate(new Date(), "GMT", "### EEEE - dd/MM/yyyy")
The code above has output ### Tuesday - 16/01/2018
You can find all available format options below:
Reference to documentation for time formatting: https://sites.google.com/site/scriptsexamples/available-web-apps/form-publisher/documentation/form-and-template-edition/date-and-time-settings#TOC-Hours-and-Minutes
Upvotes: 6