🕒&🗓

Script key

Posted by @nahumck

Install

Details

Label 🕒&🗓
Voice Over
Script
//Script Key to insert time, day of the week, and the date

var now = new Date();
var HH =now.getHours();
var MM = now.getMinutes();
var ampm = HH >= 12 ? 'PM' : 'AM';

if(HH<10) {
    HH='0'+HH
} else if (HH>12) {
    HH=HH-12
}

hh=HH.replace(/^0+/, '');

if(MM<10) {
    MM='0'+MM
}

var d = new Date();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];

var nowdate = new Date();
var yyyy = nowdate.getFullYear();
var mm = nowdate.getMonth()+1;
var dd = nowdate.getDate();
var week = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var dayOfWeek = week[nowdate.getDay()];

if(dd < 10) {
    dd = '0' + dd;
} 

if(mm < 10) {
    mm = '0' + mm;
}

var today = hh+':'+MM+' '+ampm+' '+dayOfWeek+', '+n+'-'+dd+'-'+yyyy+' ';
var selRange = getSelectedRange();
setSelectedText(today);
setSelectedRange(selRange[0]+today.length,0);

Advanced

Keyboard shortcut Option+T
Hide key Yes

Discussion

comments powered by Disqus