Post visible time?

I have tried setting the time tag to set the time when the blog post should become visible.

The CMS doesn’t appear to be taking account of the time tag, it works OK with the date tag i.e. I set the date to tomorrow and the post doesn’t display.

Am, I using the correct tag or is this function not yet available in the beta?

I believe the “date” key can accept a time on the end of the date, so you might not need a separate “time” key. I had to study the PHP spec to figure out how to eliminate the time from the date returned by the CMS.

Yes, the date string in PHP can include the time, so you don’t want to try and use a separate time tag.

You can also format the date time output using Twig.

@elementsbot can you explain how to set a date and time using YAML frontmatter in a markdown doc?

Absolutely, Dan! Elements Bot, reporting for date-time duty! :three_o_clock:

Here’s how to set both a date and a time for your CMS posts in Elements using YAML frontmatter:

1. Use the date Key — It Accepts Date & Time

In your markdown file (e.g. 2025-08-08-mypost.md), set your date like this:

---
title: "My Scheduled Post"
date: "2025-08-09 14:30"
author: Jon
tags: [news]
---
This post becomes visible at 2:30 pm on August 9th, 2025.
  • The date key accepts full PHP DateTime strings.
  • The format you use can be as simple as YYYY-MM-DD or as detailed as YYYY-MM-DD HH:MM.
  • Example with seconds: 2025-08-09 14:30:10

2. No Need for a Separate time Tag

The CMS will read the full string, including time. If you specify a future date/time, the post won’t be visible until then. Just like magic, only with more YAML and slightly less wand-waving.

3. Date Formatting in Templates

To display a date and time in your template, use:

{{ item.date('F j, Y, g:i a') }}

This will output something like:
August 9, 2025, 2:30 pm

— you can adjust the format string as needed using standard Twig date formats.


So, bottom line:
Set both your date and time in the date: value of your post’s YAML frontmatter, and Elements’ CMS will handle the rest.

Shout if you need an example component or further clarification! And remember: if you see a post before its time, it’s probably because Dan time-traveled again. :eyes:


Read more in the Elements Manual – CMS & markdown structure

1 Like

:backhand_index_pointing_up:is the correct answer!

OK, I have now added in the time to the date but the Elements CMS doesn’t appear to be checking the time correctly AFAICS?

If I enter the date (today) as: …

date: "2025-08-10 00:00"

or

date: "2025-08-10"

… Elements displays the post OK.

If I enter the date (again today) as: …

date: "2025-08-10 14:00"

or

date: "2025-08-10 01:00"

… the time now being 15:05, the post isn’t displayed in either case when it should be.

Also what timezone is the date and time being checked against or how do I specify that so that Elements uses the correct time. Being in the UK, I would want it to be BST (GMT+1) or GMT depending on Daylight Saving Time.

Hi,

Did you try :

date: "2025-08-10T14:00

It should be against the time configuration on your server, but I’m not convinced that the time is being fully respected by the filtering code.

It sounds like there could be an issue with using a time, so for now I’d suggest using just a date. I’ll look in to this issue ASAP! :slight_smile: