kaicuichen-git_Obsidian-dat.../README.md
2026-07-20 20:11:29 +01:00

3.3 KiB
Raw Permalink Blame History

Auto Date on Open

Adds today's date to a note when you open it, and only once per day. Useful for running logs, journals and lab notebooks where each visit should start a new dated section.

---
auto-date: true
---
## 2026-07-20 Monday

today's entry

## 2026-07-19 Sunday

yesterday's entry

How it works

When you open a note that is in scope, the plugin checks whether today's date is already there. If it is, nothing happens; if it is not, the date line is added — below the note's properties, never above them.

By default only notes carrying the auto-date: true property are touched, so opening the rest of your vault changes nothing.

Settings

Setting What it does
Line template The line to add. {{date}} is replaced by today's date. Anything else in the template is kept as written, so ## {{date}}, **{{date}}** and ### {{date}} — log all work.
Date format Moment.js tokens, for example YYYY-MM-DD dddd. Follows the language your interface is set to, so dddd gives Monday in English and 星期一 in Chinese.
Format used to detect an existing date Checked against the start of each line to decide whether today has already been recorded. Keep it shorter than the date format — with YYYY-MM-DD here and YYYY-MM-DD dddd above, notes stamped before you added the weekday are still recognised, so you do not get duplicates.
Position Top or bottom of the note.
Add the date when a note is opened Turn off to use the command only.
Notes to include Notes with a property, notes in chosen folders, or every note.

There is also a command, Add today's date to the current note, which works on any note regardless of scope. Give it a hotkey if you would rather add dates by hand.

Format reference

Token Result
YYYY-MM-DD 2026-07-20
dddd Monday
ddd Mon
MMMM D, YYYY July 20, 2026
YYYY 年 M 月 D 日 2026 年 7 月 20 日

Full list: Moment.js display formats.

Manual installation

Copy main.js, manifest.json and styles.css into <vault>/.obsidian/plugins/auto-date-on-open/, then enable the plugin under Settings → Community plugins.

Notes

Notes are edited through the editor when they are open in editing view, so undo works normally. Otherwise the file is updated atomically, which avoids clashing with sync or with other plugins writing to the same note.


中文说明

打开笔记时自动写上今天的日期,每天只写一次。适合日志、周记、实验记录这类"每次打开就往下续一段"的笔记。

默认只处理属性里写了 auto-date: true 的笔记,其它笔记打开时不会有任何变化。

设置项里可以自定义:插入的整行模板({{date}} 是占位符)、日期格式、判重用的格式、插在开头还是结尾、以及生效范围(按属性 / 按文件夹 / 全部笔记)。

判重格式建议比显示格式短。比如显示用 YYYY-MM-DD dddd、判重用 YYYY-MM-DD,那么以后改显示格式时,之前已经写好的日期仍然认得出来,不会重复插入。

dddd 输出的星期跟随 Obsidian 的界面语言界面是中文就是「星期一」英文就是「Monday」。

License

MIT