Created
December 29, 2016 04:07
-
-
Save pca2/e06e768d7f5fbbc69e89025e9657b8bc to your computer and use it in GitHub Desktop.
Timestamp script key for Drafts iOS
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
// ex: 2016-12-28_230652 | |
var now = new Date(); | |
var dd = now.getDate(); | |
var mm = now.getMonth()+1; | |
var yyyy = now.getFullYear(); | |
var min = now.getMinutes(); | |
var sec = now.getSeconds(); | |
var hh = now.getHours(); | |
var add_zero = function(int){ | |
if(int<10) { | |
int='0'+int | |
}; | |
return int; | |
}; | |
dd = add_zero(dd); | |
mm = add_zero(mm); | |
min = add_zero(min); | |
sec = add_zero(sec); | |
hh = add_zero(hh); | |
var date = yyyy+'-'+mm+'-'+dd+'_'+hh+min+sec; | |
var selRange = getSelectedRange(); | |
setSelectedText(date); | |
setSelectedRange(selRange[0]+date.length,0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment