Created
October 27, 2014 00:30
-
-
Save mattcassinelli/37028a686952dbcd6f3e to your computer and use it in GitHub Desktop.
Insert timestamp into Drafts
This file contains 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
function getDateTime() { | |
var now = new Date(); | |
var year = now.getFullYear(); | |
var month = now.getMonth()+1; | |
var day = now.getDate(); | |
var hour = now.getHours(); | |
var minute = now.getMinutes(); | |
var second = now.getSeconds(); | |
if(month.toString().length == 1) { | |
var month = '0'+month; | |
} | |
if(day.toString().length == 1) { | |
var day = '0'+day; | |
} | |
if(hour.toString().length == 1) { | |
var hour = '0'+hour; | |
} | |
if(minute.toString().length == 1) { | |
var minute = '0'+minute; | |
} | |
if(second.toString().length == 1) { | |
var second = '0'+second; | |
} | |
var dateTime = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second; | |
return dateTime; | |
} | |
setSelectedText(getDateTime()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script written by Gabe Weatherhead on Macdrifter: http://www.macdrifter.com/2014/10/drafts-4-keyboard-scripts.html#fn:sort
Installation instructions:
To add this to the extra keyboard row in Drafts 4, do this: