# \[V2\] set id to a timestamp?

**URL:** https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492
**Category:** How To
**Created:** [April 19, 2021, 6:18pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492 "2021-04-19T18:18:21Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![alanz](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/alanz/32/717_2.png) [@alanz](https://org-roam.discourse.group/u/alanz)
#### Post date: [April 19, 2021, 6:18pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/1 "2021-04-19T18:18:21Z")

</div>

I noticed in an [issue](https://github.com/org-roam/org-roam/issues/1470#issue-859007630) posted by @nobiot a header with some interesting properties

```auto
:properties:
:id: 2021-04-15T173128
:modified: 2021-04-15T173136
:end:
#+title: test tag 17
#+filetags: meeting

```

Questions: How do I make an `:id:` property as a timestamp, and how do I set and manage the `:modified:` property?

---

<div class="post-metadata">

### Author: ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)
#### Post date: [April 19, 2021, 8:33pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/2 "2021-04-19T20:33:17Z")

</div>

Nothing complicated.

For the time stamp (“modified” property), [I have this](https://org-roam.discourse.group/t/update-a-field-last-modified-at-save/321/22).

I then simply have `org-roam-capture-templates` to define the ID and modified properties at the head of a new Org file.

For the time stamp, just like this: `:modified: <>` (per the in-system documentation in the post I linked above, I think).

I don’t generate the ID with an Org-ID function but the normal date format (like `%Y-%m-%d` etc.)

For V1, see below. This is for my markdown front matter but it’s essentially the same for my Org. I don’t use it as is any longer as I have moved on to V2.

```auto
(setq org-roam-capture-templates
      '(("p" "personal" plain
         (function org-roam--capture-get-point) "%?"
         :file-name "personal/%<%Y-%m-%dT%H%M%S>"
         :head "---\ntitle: ${title}\nid: %<%Y-%m-%dT%H%M%S>\nmodified: <>\n---\n"
         :unnarrowed t)))

```

---

<div class="post-metadata">

### Author: ![alanz](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/alanz/32/717_2.png) [@alanz](https://org-roam.discourse.group/u/alanz)
#### Post date: [April 19, 2021, 8:55pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/3 "2021-04-19T20:55:05Z")

</div>

I was looking through the `org-id.el` source, and discovered

```lisp
(defcustom org-id-ts-format "%Y%m%dT%H%M%S.%6N"
  "Default format for IDs generated using `ts' `org-id-method'.
The format should be suitable to pass as an argument to `format-time-string'."
  :type 'string
  :package-version '(Org . "9.5"))

```

This could make setting the timestamp id really easy.

---

<div class="post-metadata">

### Author: ![Gustav](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/gustav/32/511_2.png) [@Gustav](https://org-roam.discourse.group/u/Gustav)
#### Post date: [April 19, 2021, 9:07pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/4 "2021-04-19T21:07:13Z")

</div>

the `ts` option in `org-id-method` dates back a bit further, but the custom formatting is new in 9.5. I took the opportunity before answering here to update the docstring slightly, and to squeeze in a mention of org-id-method in the Org manual… 🙂

So… I guess this answer by me isn’t really necessary any longer! Glad you found the setting on your own! 😉

---

<div class="post-metadata">

### Author: ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)
#### Post date: [April 19, 2021, 9:14pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/5 "2021-04-19T21:14:29Z")

</div>

Yes. I was just coming back to mention it. 🙂

It looks like the 9.5 version will allow for a custom formatting of the time string, which is great for me. @Gustav is that correct understanding?

The only reason I use my custom way is the formatting (I’m on Org 9.4). If you use a custom way like I do, you might then want to manually update the org-id-locations file (a [discussion here](https://org-roam.discourse.group/t/org-roam-v2-org-id-id-link-resolution-problem/1491/4)) — will not be relevant for 9.5 onwards 🙂

---

<div class="post-metadata">

### Author: ![alanz](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/alanz/32/717_2.png) [@alanz](https://org-roam.discourse.group/u/alanz)
#### Post date: [April 19, 2021, 9:23pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/6 "2021-04-19T21:23:07Z")

</div>

The other thing that struck me about the example is that `:modified:` property ends up in the property drawer along with the id.

What should a template look like to make that happen?

---

<div class="post-metadata">

### Author: ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)
#### Post date: [April 19, 2021, 10:09pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/7 "2021-04-19T22:09:49Z")

</div>

Sorry if I wasn’t clear but I had thought the markdown example above was sufficient? It’s text. I just insert `:property: \n :id: \n :end:` and so on

---

<div class="post-metadata">

### Author: ![Gustav](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/gustav/32/511_2.png) [@Gustav](https://org-roam.discourse.group/u/Gustav)
#### Post date: [April 19, 2021, 10:12pm UTC](https://org-roam.discourse.group/t/v2-set-id-to-a-timestamp/1492/8 "2021-04-19T22:12:14Z")

</div>

> [@nobiot](#):
>
> It looks like the 9.5 version will allow for a custom formatting of the time string, which is great for me. @Gustav is that correct understanding?

Locks correct to me!

Personally I’ve left the stable releases of Org a long time back, living on Org mode master (using Straight package manager, to ease with the configuration management). And on Org mode master this (ofc.) already is implemented.
