script to show post time next to date on bear blog
This JavaScript snippet adds the post time next to the date on single post pages in Bear Blog. You might find this useful if you post often, publish multiple posts per day, or use Bear Blog for microblogging.
## How Bear's date system works
Bear Blog already has its own [date formatting script](tab:https://github.com/HermanMartinus/bearblog/commit/0fb2efd) that runs on every page. This script:
- Finds all `` elements on the page
- Formats them according to your blog’s date format setting
- Uses a format string like “d M, Y” or “d, M Y”

And my script works on top of Bear's existing script:
1. Waits for Bear's script to format the date first
2. Then adds the time information to single post pages
## How to use
1. **Copy the minified script** from [show-post-time-bear-blog-min.js](tab:https://gist.github.com/verfasor/e7c899536f74a575509f10b26ab19d91)
2. **Go to your Bear Blog dashboard** → Settings → Header and footer directives → Footer directive:
3. **Paste the script** into the input field
4. **Save** - The script will automatically work on all your single post pages
If you want to host the script elsewhere (better for reusability):
1. Upload the [show-post-time-bear-blog.js](tab:https://gist.github.com/verfasor/d558f68a26cab44a70408fa6e87b07c9) to a CDN or your own hosting
2. Replace the inline script with:
```html
```
## Examples
**For posts published today:**
```
Today • 05:05 PM
```
> **How "Today" is calculated**: The script reads each post's timestamp from the dateTime attribute of the `` element. It compares the post's calendar day, month, and year to the viewer's current local date. The comparison uses the viewer's local timezone, what counts as "today" automatically adjusts for the reader's location.
**For posts published on other days:**
```
23 Nov, 2025 • 05:05 PM
```
> **Important:** I haven't double-checked if a built-in `{{time attribute}}` exists in Bear (please refer to docs.bearblog.dev).