Reputation: 4405
So I've now got this great timestamp inside a code snippet in VS Code.
Full snippet:
"Frontmatter":{
"prefix": "sqFront",
"body": [
"---",
"title: $1",
"permalink: $2",
"description: $3",
"date: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}Z",
"tags:",
"- $0",
"---"
]
}
How do I set the snippet to capture UTC time instead of my local time?
Upvotes: 0
Views: 801
Reputation: 28783
You can use the HyperSnips extension:
Define the following snippet in the language.hsnips
file or in all.hsnips
file if you want to have it many file types
snippet sqFront "Frontmatter" b
---
title: $1
permalink: $2
description: $3
date: `` d = new Date();
twodigit = n => n.toString().padStart(2,'0');
rv = `${d.getUTCFullYear()}-${twodigit(d.getUTCMonth()+1)}-${twodigit(d.getUTCDate())}T${twodigit(d.getUTCHours())}:${twodigit(d.getUTCMinutes())}:${twodigit(d.getUTCSeconds())}Z` ``
tags:
- $0
---
endsnippet
Upvotes: 1