Copy link to clipboard
Copied
In the docs it says this:
date
Here are the available switches:
%d
- outputs the day of the month - 18%M
- outputs the month of the year - 6%y
- outputs the year - 14
To output 14-06-18 use {{dateVariable | date: "%y-%M-%d"}} (mind the double quotes).
I then try the following on my site: {{dateVariable | date: "%y-%M-%d"}} when it renders on the site it shows like this: {{dateVariable}}.
Is this a bug or are the docs incorrect?
While on the topic of date is there no way to get the Day of the Week? IE: Sunday, Monday, etc.
For that matter will we have all of the options available that Liquid has? I was looking at the Shopify Liquid docs on date. Will be be able to access all of these?
Hi Lynda,
Where are you getting the date value from? I mean what date do you assign to the "dateVariable" variable? If possible please let me know a sample page where you have this setup implemented, I will have a look,
The date switches at the Shopify page will not work because we are using a different Liquid implementation. From the next release however we will add alot of new date type filters, almost all of the switches here will work: Custom Date and Time Format Strings
Thanks,
Mihai
Copy link to clipboard
Copied
Hi Linda,
To answer your last question (without a clue, mind you), I'm sure we'll eventually be able to use the rest of the date filters, but I doubt they are very high up the list of priorities right now. That said, it could be a nice feature request to add to the ideas.
Was your dateVariable outputted from a date-time field in a BC module?
Copy link to clipboard
Copied
Hi Lynda,
Where are you getting the date value from? I mean what date do you assign to the "dateVariable" variable? If possible please let me know a sample page where you have this setup implemented, I will have a look,
The date switches at the Shopify page will not work because we are using a different Liquid implementation. From the next release however we will add alot of new date type filters, almost all of the switches here will work: Custom Date and Time Format Strings
Thanks,
Mihai
Copy link to clipboard
Copied
Hi Mihai,
I think I may be using it incorrectly. If I wanted to spit out just the year how would I do that?
I will be looking forward to the next release! Adding more date and time switches will be great!
Thank You!
Copy link to clipboard
Copied
I just realized I wasn't actually defining the variable. Oops! It is working now. I am looking forward to the new date features! Have many uses for them.
Copy link to clipboard
Copied
With the next release we will have methods for outputting the current date as well. You will be able to build something like "show me the products released in the last 2 days". We will build how to articles for the date scenarios as soon as they're out.
Happy holidays,
Mihai
Copy link to clipboard
Copied
Awesome! Very useful. Looking forward to it! Thank You!
Happy Holidays!
Copy link to clipboard
Copied
Woohoo!! New date filters for Liquid! Thanks BC team!
Copy link to clipboard
Copied
I actually saw that this morning too Adam, about another 30 date filter options available to us.
Definitely a Woohoo moment!
Copy link to clipboard
Copied
Hi guys,
The new date switches will be available from the next release (early next week). We'll have some more how to articles and samples for date comparisons and rendering options
Thanks,
Mihai
Copy link to clipboard
Copied
Awesome! Looking forward to the next release.
Copy link to clipboard
Copied
Any news on this?
I would like to be able to have a variable that could show the current date and month seperately.
I would think that i could use the "old" {module_today} and "split" them up, but this sounds much nicer.
I am doing a birthday app, that can display employees birthday on a "internal" website for a client of mine.
At the moment i am working on something like this:
{% for item in items %}
{% if {{item.['Birthday-month']}} contains "January" %}
{% if {{item.['Birthday-day']}} contains "13" %}
<div class="birthday">
<div class="name">Happy birthday to {{item.name}}</div>
</div>
{%endif %}
{%endif %}
{%endfor%}
Where "January" and "13" should be the current date variable.
Not sure if this is the way to do it, but works so far
Copy link to clipboard
Copied
Just look at Cristenels post Peter. See whats in the next release. You already have filters for data you can see on the doc reference.
Copy link to clipboard
Copied
Hi Liam
Is it first possible to do this tomorrow after the update, or is it possible with the current filters to get current month and date?
I've been using {{releaseDate | date: "%d"}} for some other things on the site, but is there a similar one to display current date available now?
Copy link to clipboard
Copied
Not till the release because the global object will contain the system date. You can use that and the proper iso time stamp for an item and compare them properly.
Copy link to clipboard
Copied
Great. That was what i understood from reading the post, but didn't know if I had missed something.
I'll just have to wait until tomorrow. Nearly perfect timing though!
Copy link to clipboard
Copied
This is awesome, works great.
I have done this, and works fine. (maybe the code could be nicer?)
{% assign birthdayDay = Globals.Site.DateNow| date: "%d" %}
{% assign birthdayMonth = Globals.Site.DateNow| date: "%M" %}
{% for item in items %}
{% assign birthdayYear = {{item.['Birthday-year']}} %}
{% if {{item.['Birthday-month']}} == birthdayMonth %}
{% if {{item.['Birthday-day']}} == birthdayDay %}
<div class="birthday">
<br>
<div class="name">Happy birthday to {{item.name}}</div>
<br>
</div>
<br>
<br>
{%endif %}
{%endif %}
{%endfor%}
Just a question.
I can get this tag working fine {{Globals.Site.DateNow| minus: "2015-01-15"| date: "%d"}}.
It is great that it is now possible to calculate, but what if I want to calculate with a "variable".
The thing I want to achieve is that you also can display how old the person is on his/hers birtday.
I've made this {% assign birthdayYear = {{item.['Birthday-year']}} %}
And i thought I could combine it with {{Globals.Site.DateNow| minus: "2015-01-15"| date: "%d"}}
in something like {{Globals.Site.DateNow| minus: {{birthdayYear}}| date: "%y"}} or something like that,
but I can't get it to work, I think that the format on the two dates i am trying to compare is not working,
because I am trying to compare a "complete" date with only the year.
Hope it makes sense, and somebody can give me a pointer
Copy link to clipboard
Copied
and is now there for your if statements as a note
But what your after is the inclusion of data types in BC as of the latest release
http://docs.businesscatalyst.com/developers#!/liquid/datatypes
So you can convert your custom text field to a data and then run your checks, in fact you can do heaps. BC did an awesome job on this stuff!
Copy link to clipboard
Copied
THX LIAM!
Just what i needed. Didn't notice the "convert" before you pointed me in the right direction.
Ended up with this and it seems to be working
{% assign birthdayDay = Globals.Site.DateNow| date: "%d" %}
{% assign birthdayMonth = Globals.Site.DateNow| date: "%M" %}
{% for item in items %}
{% assign birthdayYearVar = {{item.['Birthday-year']}} | convert: "number" %}
{% assign birthdayCalc = globals.site.dateNow | date: "yyyy" | minus: birthdayYearVar %}
{% if {{item.['Birthday-month']}} == birthdayMonth %}
{% if {{item.['Birthday-day']}} == birthdayDay %}
<div class="birthday">
<br>
<div class="name">Happy birthday to {{item.name}}</div>
<br>
<br>{{item.name}} turns {{birthdayCalc}} years old today.
</div>
<br>
<br>
{%endif %}
{%endif %}
{%endfor%}
Thx again Liam!
Copy link to clipboard
Copied
No Problem, have a go at using and as well and you can get that code even tidier. Worth doing. New stuff, get into the habit earlier the better.
Also see the minus sign at the end of this example below? This means it will supress the white space in your markup. View the page source where you just did the above, you will see what it looks like without
{% if {{item.['Birthday-month']}} == birthdayMonth -%}
Copy link to clipboard
Copied
Thx Liam, I will look into that!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now