I have a variable {{value.time}}
in this value executes
March 22, 2013, 2:30 a.m
But I want to remove the 2:30 a.m
(time) for this value in my templates file. How could I do this?
Select the cell, right-click on it choose Format Cells… Step 2: Then in the Formal Cells box select Custom in Category and in the type select dd-mm-yyyy hh:mm, and then click Ok. Then, we will enter our date with time in the cell.
Put date as extension
{{ value.time.date }}
>>> from datetime import datetime,date
>>> date_str = 'March 22, 2013, 2:30 a.m'
>>> date_str = date_str.replace('a.m','AM')
>>> formatter_string = "%B %d, %Y, %I:%M %p"
>>> datetime_object = datetime.strptime(date_str, formatter_string)
>>> date_object = datetime_object.date() # date object without '2:30 AM'
>>> date_object
datetime.date(2013, 3, 22)
>>> formatter_string = "%B %d, %Y"
>>> datetime_string = datetime.strftime(date_object, formatter_string)
>>> datetime_string
'March 22, 2013'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With