Add hour to a date

Hi there,

I’m trying to add a specific amount of time (for example, 1 hour) to a date from an ACF Date-Time picker. I’ve seen the parameter add="1 week" in the documentation, and was wondering: does the parameter add="1 hour" exist? If not, is there any way I can achieve this?

Best regards,


I think that add="1 hour" should work. Have you tried it?

My understanding is that the add and subtract attributes seem to accept a pretty wide range of plain text time descriptions in their value. I assume this draws on some library that’s external to L&L, but it’s not clear in the documentation exactly how that works or what format it accepts. I bet it’s similar to how the Date tag is able to ‘intelligently’ figure out what your date format is without you needing to tell it exactly. I’ll see if I can get some clarifications about how that works from the devs and I’ll post my findings here.

Hi Benjamin,

Thanks for your answer. I’ve tried it indeed, but it didn’t work even though I managed to make it work with the add="1 week" and the date. So it looks like the code is not faulty, although it might have to do with the date format, if this is supposed to work and it doesn’t. I just wanted to ask if it should before fiddling more with it. I’ll keep trying then, thanks!

Seems to work for me. I think by default, the Date tag just outputs a date, so if you want to output a time too, you might need to specify that with a format attribute. Here’s an example of what I just tested:

<Date format="Y-m-d H:i:s" add="1 hour">2022-10-21 21:00:00</Date>

The output of the template above is 2022-10-21 22:00:00, which is an hour ahead, as you’re trying to do. Let me know if you figure out what you might be doing differently that seems to be causing an issue for you.


To clarify, the default output of this:

<Date add="1 hour">2022-10-21 21:00:00</Date>

Is this: October 21, 2022

That’s not wrong, it’s just that the default output of the Date tag doesn’t seem to show the time, so if you want to display the time in some format, you’ll need to specify what format you want to use.

1 Like

Okay, that did it for me. My mistake, I think, was to put the format parameter with the ACF field, like this:

<Date add="1 hour"><Field acf_date_time=field_name format="Y-m-d H:i:s" /></Date>

Whereas it should have been wrapped with the Date as you did, this way:

<Date format="Y-m-d H:i:s" add="1 hour"><Field acf_date_time=field_name /></Date>

Thanks for your guidance :blush: