# Post Toolbar Options - Timestamp?

**URL:** https://meta.discourse.org/t/post-toolbar-options-timestamp/51853
**Category:** Feature
**Created:** [October 21, 2016, 12:42pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853 "2016-10-21T12:42:30Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [October 21, 2016, 12:42pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/1 "2016-10-21T12:42:30Z")

</div>

Hi,

Often I find users (myself included) returning to the same post and updating it with some new content, I would typically do something like this;

_Update_

Now I have discovered this etc etc..

As this can happen on multiple occasions for the same post, I thought it would be beneficial to be able to click a button on the post toolbar (bold, italic, underline etc) and have a TimeStamp inserted, there doesn’t appear to be an option for this at this time, nor was I able to discover any shortcut (by typing) to make it appear.

Potentially the output may look like;

blah blah blah

_Update 21/10/2016 13:39_

something new was discovered

_Update 21/10/2016 13:41_

something even newer was discovered here..

I fully appreciate this can be achieved manually, but a feature button to insert it for you would be, well, kinda time saving 🙂

I should add, this would be a post CONTENT timestamp, not a timestamp used against the actual posting of the message as it were (I see there are lots of posts on here regarding that)

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [October 21, 2016, 8:41pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/2 "2016-10-21T20:41:33Z")

</div>

> [@RobMeade](#):
>
> I fully appreciate this can be achieved manually, but a feature button to insert it for you would be, well, kinda time saving 🙂

Things that are just “kinda sorta useful” tend to fall into plugin territory 😉 I do end up doing this type of update myself from time to time, but not nearly often enough that I feel like I’d save a significant amount of time by having a dedicated function for it.

---

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [October 21, 2016, 9:56pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/3 "2016-10-21T21:56:00Z")

</div>

> [@erlend\_sh](#):
>
> I do end up doing this type of update myself from time to time

There is a large sense of relief that it’s not _only_ me 🙂

Well, Santa will soon be on his way so I thought I’d put my requests in now, I have been good ~~all year~~ on occasion, after all! 🙂

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [October 21, 2016, 10:57pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/4 "2016-10-21T22:57:41Z")

</div>

Add this to your Admin \> Customize \> CSS/HTML \> `</head>`

```plaintext
<script type="text/discourse-plugin" version="0.4">
    api.onToolbarCreate(toolbar => {
      toolbar.addButton({
        id: "updated_button",
        group: "extras",
        icon: "clock-o",
        perform: e => e.addText("Updated " + new Date().toString())
      });
    });
</script>

```

---

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [October 23, 2016, 4:22pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/5 "2016-10-23T16:22:47Z")

</div>

Hi @cpradio, sorry for the delay responding.

Thank you for spending the time putting that together and sharing, appreciated. I don’t have the ability on the site to implement it (lowly moderator) but I will pass it over to those that do and see if they are willing.

Thanks again, really appreciated 🙂

Kind regards

Rob

---

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [December 20, 2016, 11:21pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/6 "2016-12-20T23:21:41Z")

</div>

Just a quick question to re-open this if I may…

I spotted that when this was being used the time stamp was quite long, looking at the various options using JavaScript to shorten the date it seemed incredibly complex, from what I could tell the desired output would always be 21 characters long so went with a bit of a hacky way of doing this…

```
<script type="text/discourse-plugin" version="0.4">
    api.onToolbarCreate(toolbar => {
      toolbar.addButton({
        id: "updated_button",
        group: "extras",
        icon: "clock-o",
        perform: e => e.addText("_Updated " + new Date().toString().substring(0,21) + "_")
      });
    });
</script>

```

I then spotted that the hover text didn’t display a name correctly - so we have added this

`title: "Updated Timestamp",`

thus;

```
<script type="text/discourse-plugin" version="0.4">
    api.onToolbarCreate(toolbar => {
      toolbar.addButton({
        id: "updated_button",
        group: "extras",
        icon: "clock-o",
        title: "Updated Timestamp",
        perform: e => e.addText("_Updated " + new Date().toString().substring(0,21) + "_")
      });
    });
</script>

```

but the output in the hover text appears as `[en.Updated Timestamp]`

Anyway to remove the square brackets and the `en.` part?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [December 20, 2016, 11:49pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/7 "2016-12-20T23:49:48Z")

</div>

Try this:

```plaintext
<script type="text/discourse-plugin" version="0.4">
    api.onToolbarCreate(toolbar => {
      I18n.translations.en.js.updated_timestamp = "Updated Timestamp";
      toolbar.addButton({
        id: "updated_button",
        group: "extras",
        icon: "clock-o",
        title: "updated_timestamp",
        perform: e => e.addText("_Updated " + new Date().toString().substring(0,21) + "_")
      });
    });
</script>

```

---

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [December 20, 2016, 11:53pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/8 "2016-12-20T23:53:21Z")

</div>

wow - thanks for such a prompt response! Really appreciated…

I _worked out_ (term used very loosely) the `title:` part from looking at the page source for the other icons, but wouldn’t have guessed the other line you’ve added - I will forward this on to our admins and see if they can update this for me.

Thank you so much - minor thing really, but will look so much better when I use it! (OCD = True) 😃

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [December 20, 2016, 11:55pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/9 "2016-12-20T23:55:39Z")

</div>

Yeah, no worries. One thing to help explain it, the title attribute is looking for a translation entry with that key. So I simply created a key and assigned it the verbiage you wanted and then specified that key in the title attribute. 🙂

---

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [December 20, 2016, 11:57pm UTC](https://meta.discourse.org/t/post-toolbar-options-timestamp/51853/10 "2016-12-20T23:57:50Z")

</div>

Thanks 🙂

I didn’t even realise that there were language translations going on! Can’t wait to see this finished, it’s been really handy when updating existing posts rather than creating multiple replies 🙂
