I currently am working on a project, where I have to render events and I am stuck with the date format.
My variable {{ event.start }} renders this date in the website: 2021-08-27T00:00:00+02:00[Europe/Vienna]
When I want to return this date with the right format like that
{{ event.start|date("d.m.Y") }}
it shows this date, which is not true: 31.07.2021 (it should be 27.08.2021)
Any ideas what I am doing wrong?
Related
I have a site build with several different variations of time and date throughout the site as well as a format needed for outputting to a calendar export file for Gmail/Outlook/iCal. I'd like to only use one field, the combo date and time picker, but I can't get it to work for all the custom formats. Is there any way to have more than one return format?
If I could have a Ymd and a Y/m/d H:i that would cover everything.
I'm trying to find the date and time difference between two unix values. In HuBL, I have currently:
{% set event_date_and_time = table_data_dict.event_time|unixtimestamp %}
{% set current_time_and_date = local_dt|unixtimestamp %}
{% if current_time_and_date >= event_date_and_time %}
event is live
{% else %}
event is not live
{% endif %}
table_data_dict.event_time is the value from the date and time field in the database.
Running the following:
Event: {{ event_date_and_time }} <br>
Current: {{ current_time_and_date }}
Produces the following results:
Event: 1596623700000
Current: 1596620020929
Test scenarios:
Test 1:
The date and time I have set in the database (what event_date_and_time is) is 10th August 2020 12pm.
The if statement echos event is not live - which is correct.
Test 2:
The date and time now, in the database is set to a day before todays date (so 4th august 2020 12:00pm) - the event is essentially live.
The if statement echos event is live - which again, is correct.
Test 3:
Now, currently for me, it's 11:00am (5th Aug 2020). If, in the database, I change the date and time to 5th August 2020 11:10am. It produces the following results:
At 10:55am, when I check the if statement, it will say event is not live (correct, it's live at 11am).
Now, when I check at 11am (when the event is live) it says event is not live.
When I continue to wait and check again at 11:05am, it still says event is not live.
Unsure why? I have cleared cache, it's not a caching issue, unsure why it's performing like so?
So, I'm working on a template where I have a merge variable, dateSubmitted. This variable comes from an API where it's formatted as so:
dateSubmitted = 2017-09-13GMT22:25:45.513+00:00
I'm trying to insert this date in a slightly nicer way into an email, so in my Mandrill template (using Handlebars) I'm doing the following:
<li><em>Date Submitted:</em> {{date dateSubmitted}}</li>
However, my date continues to display in the email as 2017-09-13GMT22:25:45.513+00:00. What am I doing wrong?
Stumble upon this too. After an hour I re-read the docs, where is stated, that this inline helper is used to
print the current date with a given format, defaults to d/m/Y
So, it is not for formatting your variables but for just displaying current date in custom format.
I am trying to add a query string to a link in my twig file for the purpose of jumping to today's agenda in jQuery FullCalendar, but the months are based on a 0-11 structure rather than the standard 01-12.
I am using the following string to generate the query in my twig template:
View Today's Agenda
But using the "date_modify" and "-1 month" will not work if it's January as it will render "12" instead for the previous December. So, if it's January it needs to show as "0".
Is the way of doing this in Twig? It's not practical for me to render it in my Controller PHP as I'd have to do it many times due to my extensive range of pages in my CRM.
Thanks in advance
Michael
Try:
&m={{ ("now"|date("m"))-1 }}
I have an Entity called Event, with fields startDate, startTime, endDate and endTime. startDate and endDate are dates of which endDate can be NULL if it is the same of startTime (I can change this behaviour if it makes things easier as I have no events yet). startTime and endTime can not be NULL. It also has an isOnDate(\DateTime $date) method, which returns true if the event will run on the given date.
It was like pain, but I finally generated an HTML table of any given calendar month, passing the day of week of the month's first day (firstDow) and the number of days in that month (numDays) as template variables.
The next step would be to make some table cells links to event or event listing pages if the given days has one or more events. Now I'm a bit stuck, as I don't know how to get the DateTime() object of each cell in a template.
Can someone give me a hint on this? Or am I making it totally wrong?
You can display DateTime Objects as Text Dates using Twig Filter date:
{{ event.startDate|date("m/d/Y") }}
You could use Ajax and jQuery to link dynamically your page with your database. You could start from this calendar code for Symfony2: http://www.symfocal.com