Help with date and time

I just can’t search on this topic any longer. I am trying to understand how date and time inputs work. Prior to OBS I have never heard of markdown. It’s been challenging as an understatement partly because I am not like many on here - I don’t write code or scripts or plug-ins or whatever else many on here do. I use software as a means to an ends not the end itself.

I read many posts on here and other sites but still have no idea;

I believe time and date formats cannot be entered into an edit pane directly they need to be entered into a template only in order for them to calculate correctly on the note the are imported into?

Well mine still don’t work using that method all I get is the text output.

I think the date time formats are not limited to areas such as daily notes or daily planner the date / time should work in any note?

The only format that has worked for me is the following style:

<% tp.date.now(“YYYY-MM-DD HH:mm”) %>

None of the other formatting i see with the {{ }} produces any results. I have tried with and without the metadata formatting I think that is what its called -. I have also seen # {{xxxx}} and that also produces no results.

I am aware of the natural language plugin and text expanded options.

Does anyone know of a resource out there I can go to that explains date and time formatting in simplest form?
Thanks.

1 Like

I don’t use a lot templates or similar (nor daily notes). By that, I’m not the best bet to advice you.
But I think you need to clarify the differences between the core plugin “Templates” and the community plugin “Templater”.
Templates uses date formats similar to {{date}}; Templater uses internal functions as tp.date.now().
For Templates see Obsidian Help Vault or online help: Templates.
For Templater see plugin documentation: Syntax | Templater.

3 Likes

I am not a regular user of template either but I think the difference between those two are Templates are inserted at the creation of the note and Templater allows the insertion of templates after the note is created. I think that was what I read on them. Nevertheless I have tried setting up date/time format using both; creation as well as insertion afterwards no change in results.

You can insert both (template from Templates or Templater) when and where you want.
Test this:

  1. Create a template, in defined Templates folder, with this:
{{date}}
  1. Create a new note (or use an existent one) and insert the template created in 1. in any place. It works?

BTW, you can call the “Command palette” with the hotkey Cmd+P (macOS) or Ctrl+P (Windows) and start writing “Templates”… Then you find options like “Templates: Insert template”, “Templates: Insert current date” or “Templates: Insert current time”. (For “current date” and “current time” you don’t need any template).

Negative does not work. See attached.

I am aware of the shortcuts started using the Ctrl+P / Inert templates; but then graduated to Alt+E to pull up the templates directly. Thanks for the tip.

1
2
3

  1. With codeblocks? For test use a simple expression {{date}} without codeblock!
  2. Are you sure Alt+E is for Templates or for Templater?

I think you continue to use Templater and not Templates.

Ok so it is working now.

First I went back in and deleted the codeblock and still the same result. I am not sure why it created a codeblock I did not type that I just copy and pasted the text you had in the box above not the entire block but pasted and it created.

I was using Alt+E which opens the dropdown list of available templates. Templates and Templater pull from the same available templates in the same designated folder. I had not modified any setting in the Tamplater base setting yet all I did was assign the template folder path and the hotkeys I made no other adjustments.

So I now went in and disabled the Templater plugin and Alt+E no longer worked. I had to go back to using Ctrl+P / Insert templates; which then brought up the list of templates; these are the same templates that come up when using Alt+E but they are arranged differently for some reason. When I did the insert this way the date/time worked correctly.

In my OP above I stated the only t&d functions that were still working using the Alt+E from Templater was <% tp.date.now(“YYYY-MM-DD HH:mm”) %> but not the { }. Now with using Ctrl+P the { } work fine but “<% tp.date.now(“YYYY-MM-DD HH:mm”) %>” does not work it only works using Templater. I don’t understand these differences.

It also looks like t&d only works when being brought in via template it doesn’t work when simply keyed in?

Thanks for the assistance.

As I said in my first post, you need to clarify the differences between the two plugins: Templates (a core plugin); Templater (a community plugin).
Without this clarification, it’s easy to misreading the hotkeys, the functions, etc.
Alt+E is a hotkey for Templater, not to Templates.
If you disable Templater, the hotkey and expressions like <% tp.date.now(“YYYY-MM-DD HH:mm”) %> don’t work!
In your left sidedock (in default theme) you can find a shortcut to each plugin (if activated):
image
The first is for Templates, the second for Templater.
To avoid confusion, define different folders to each one (in settings).

Yes, you need to place them via templates because the plugin is ‘activated’ in that way.
If you install the plugin “Hotkeys for templates” you can add a specific hotkey for each template you want! In this way you can define an easy way to insert the template.
One example. Obsidian markdown didn’t have the “underline” style (only possible using html tags <u>my underlined text</u>). Using Templater I create this template

<u><% tp.file.selection() %></u>

and with “Hotkeys for templates” I define “Cmd+U” (macOS) as the hotkey to insert this template. When I need to ‘call’ the template I select the text I want to underline and insert the template using the keyboard shortcut “Cmd+U”. Et Voilá!

EDIT (an update)
Now the Templater plugin has the functionality to define hotkeys. The “Hotkeys for templates” is unnecessary if you need shortcuts only for templates in Templater (for Templates you still need it).

2 Likes

Thanks understood.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.