Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove time in date time function?

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?

like image 504
user2169287 Avatar asked Mar 22 '13 09:03

user2169287


People also ask

How do I remove time from date and time column?

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.


2 Answers

Put date as extension

{{ value.time.date }}
like image 51
catherine Avatar answered Sep 19 '22 01:09

catherine


>>> 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'
like image 26
Davit Avatar answered Sep 21 '22 01:09

Davit