Skip to content

Instantly share code, notes, and snippets.

@Matsuyanagi
Last active January 6, 2018 17:58
Show Gist options
  • Save Matsuyanagi/7abbb46f4ea230703fd9c098fc52bcd0 to your computer and use it in GitHub Desktop.
Save Matsuyanagi/7abbb46f4ea230703fd9c098fc52bcd0 to your computer and use it in GitHub Desktop.
CreateLink で $%date%$ 日付、$%time%$ 時刻を置き換えるフィルタ
return ((s)=>{const d = new Date();const yyyy = d.getFullYear();const mm = ("0"+(d.getMonth()+1)).slice(-2);const dd = ("0"+d.getDate()).slice(-2);const date = `${yyyy}-${mm}-${dd}`;const hh = ("0"+d.getHours()).slice(-2);const mi = ("0"+d.getMinutes()).slice(-2);const sc = ("0"+d.getSeconds()).slice(-2);const time = `${hh}:${mi}:${sc}`;s = s.replace( /\$%date%\$/, date );s = s.replace( /\$%time%\$/, time );return s;})(s);
/*
return (
(s)=>{
const d = new Date();
const yyyy = d.getFullYear();
const mm = ("0"+(d.getMonth()+1)).slice(-2);
const dd = ("0"+d.getDate()).slice(-2);
const date = `${yyyy}-${mm}-${dd}`;
const hh = ("0"+d.getHours()).slice(-2);
const mi = ("0"+d.getMinutes()).slice(-2);
const sc = ("0"+d.getSeconds()).slice(-2);
const time = `${hh}:${mi}:${sc}`;
s = s.replace( /\$%date%\$/, date );
s = s.replace( /\$%time%\$/, time );
return s;
}
)(s);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment