I tried using the following:
yamlCopy code
---
created: YYYY-MM-DD
modified: YYYY-MM-DD
---
but it’s not being applied
I want to add creation and modification dates to my template files, but it’s not working. Please help me!
I tried using the following:
yamlCopy code
---
created: YYYY-MM-DD
modified: YYYY-MM-DD
---
but it’s not being applied
I want to add creation and modification dates to my template files, but it’s not working. Please help me!
If you’re using Templater for your templates, you can do it like this:
---
created: <% moment().format() %>
---
For modified date you’ll need a plugin to update that for you, as Obsidian doesn’t have a built-in way of automatically updating that field:
Try:
---
created: <%tp.date.now("YYYY-MM-DD")%>
modified: <%tp.date.now("YYYY-MM-DD")%>
---
Both of the above examples use Templater. If you use the core template plugin, try this:
---
created: {{date:YYYY-MM-DD}}
modified: {{date:YYYY-MM-DD}}
---
The update time on edit plugin is the one that I use to keep these up to date (I haven’t tried Alan’s though)
I use these normally as the last two keys in my YAML.
E.g. if I right click on my Computer folder to create a new note, this Template will be applied:
<%*
let title = tp.file.title
if (title.startsWith("Untitled")) {
title = await tp.system.prompt("Title");
await tp.file.rename(title);
}
tR += "---"
%>
title: <%* tR += title %>
aliases:
-
tags:
- computer
publish: false
date created: <% tp.date.now("YYYY-MM-DD")%>
date modified: <% tp.date.now("YYYY-MM-DD")%>
---
# <%* tR += title %>
<% tp.file.cursor(1) %>
Is there a way to add time as well?
My first reply in in the thread has time as well as timezone.
You can find the options for formatting moment here:
I successfully applied the advice from helpful individuals. Thank you very much.