Add exactly 10 days (to the minute) to an input_datetime?

This one has me a bit lost.

I just need to have exactly 10 days added to an input_datetime i have set, then set that value to a different input_datetime var.

What i cant figure out is how to set a date 10 days from now and the template know the correct date? Example, if its at June 27, 2020, 10 days would bring it into July, and specifically, July 7, 2020.

Add 864000, which is the number of seconds in ten days.

It was actually tracked in hours in my case. This did the trick with the formatting i wanted. Thanks


G6 Sensor Start:     {{ state_attr('input_datetime.cgm_sensor_start', 'timestamp') | timestamp_custom('%B %-d, %Y')}} // {{state_attr('input_datetime.cgm_sensor_start', 'timestamp') | timestamp_custom('%-I:%M %p') }}

G6 Sensor Expiry:    {{ (state_attr('input_datetime.cgm_sensor_start', 'timestamp') + 864000) | timestamp_custom('%B %-d, %Y')}} // {{state_attr('input_datetime.cgm_sensor_start', 'timestamp') | timestamp_custom('%-I:%M %p') }}

OUTPUT:

G6 Sensor Start: June 27, 2020 // 2:20 AM
G6 Sensor Expiry: July 7, 2020 // 2:20 AM

I don’t know exactly what you mean by this, but linux stores time as an integer which is expressed in seconds (since 1.1.70).

Glad whatever you are meeding this for is working :slight_smile:

What i meant was, I’m actually really stupid and cant count digits apparently… :roll_eyes:

You were totally right with the + 864000 value (in seconds)

1 Like

It would appear you are smart enough to work out templating, so I guess not that stupid!

Ha, i guess thats a question we’d have to base off variables lol

“If a rocket scientist can’t make toast; is he still considered smart?”