I have a date and time code, that looks like this:
202203251159
I would like to know the minutes from {{ now().strftime("%Y%m%d%H%M") }}
.
What would be the best/easiest way to do that?
I have a date and time code, that looks like this:
202203251159
I would like to know the minutes from {{ now().strftime("%Y%m%d%H%M") }}
.
What would be the best/easiest way to do that?
The minutes portion of that datetime, total minutes for the day, epoch, or what?
Also: The EPIC Time Conversion and Manipulation Thread!.
And did you read the templating docs?
Use pythonâs inherent ability to slice strings. This slices the last two characters of the supplied string:
{{ states('sensor.your_sensor)[-2:] }}
On the other hand, if all you want is the minutes of the current time, then itâs simply this:
{{ now().minute }}
I want the absolute difference in minutes. They are in the same time zone.
Youâre not providing enough information in your posts and weâre left with guessing what you want.
For example, your latest post introduces a requirement that wasnât mentioned in your first post. You now want the âabsolute difference in minutesâ. The difference between what two things?
Maybe lost in translation but I wanted to have the difference between 202203251159
and now().strftime("%Y%m%d%H%M")
.
Sorry, if this wasnât clear.