Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MTのブログ記事の公開日に現在時刻をセットするボタンを挿入
jQuery(function($){
var btn = $('<button class="button mt-edit-field-button"></button>')
.text('公開日を現在時刻に設定')
.click(function(){
if (confirm('公開日時を変更していいですか!?') == false) {
return false;
}
stamp();
return false;
});
$('#authored_on-label').after(btn);
// ブログ記事のbasenameを現在時間にする
function stamp () {
toggleFile();
var now = new Date();
var yyyy = now.getFullYear();
var mo = $.digit(now.getMonth() + 1);
var dd = $.digit(now.getDate());
var hh = $.digit(now.getHours());
var mi = $.digit(now.getMinutes());
var ss = $.digit(now.getSeconds());
var dateTime = '' + dd +'-'+ hh + mi + ss;
document.entry_form.authored_on_date.value = '' + yyyy + '-' + mo + '-' + dd;
document.entry_form.authored_on_time.value = '' + hh + ':' + mi + ':' + ss;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment