Im trying to display course_start_date with time but without Time Zone (11 Jan 2020 15:00)
I was tried changing data-format="shortDate" (display only date) and removing z from course_date_string = course_start_date.strftime('%Y-%m-%dT%H:%M:%S%z') but without success.
Expected output: 1 Jan 2020 15:00
<%block name="course_about_important_dates">
<ol class="important-dates">
<li class="important-dates-item">
<span class="icon fa fa-info-circle" aria-hidden="true"></span><p class="important-dates-item-title">${_("Course Number")}</p><span class="important-dates-item-text course-number">${course.display_number_with_default}
</span>
</li>
% if not course.start_date_is_still_default:
<%
course_start_date = course.advertised_start or course.start
%>
<li class="important-dates-item">
<span class="icon fa fa-calendar" aria-hidden="true"></span>
<p class="important-dates-item-title">${_("Classes Start")}</p>
% if isinstance(course_start_date, string_types):
<span class="important-dates-item-text start-date">
${course_start_date}
</span>
% else:
<%
course_date_string = course_start_date.strftime('%Y-%m-%dT%H:%M:%S%z')
%>
<span class="important-dates-item-text start-date localized_datetime" data-format="ISODate" data-datetime="${course_date_string}" data-language="${LANGUAGE_CODE}"></span>
% endif
</li>
% endif
You should use the right formatting string to achieve 1 Jan 2020 15:00
:
%d
for the day, %b
for the month shortname, %Y
for the full year, %H
for the hour and %M
for the minute.
Below, a snippet with an example:
# [Code]
from datetime import datetime
course_start_date = datetime.now()
print(course_start_date.strftime('%d %b %Y %H:%M'))
# [Output]
"23 Sep 2019 18:10"