Date Filters These date filters allow you to modify the formating of dates in some pretty cool ways! Now! When working with dates you'll often want to get the current date/time. This is possible with the 'Now' keyword. You can use in places where you'd normally input a date/time to use the current date/time. Consider the example below which would display today's date like '3/7/2021'. {{ 'Now' | Date:'M/d/yyyy' }} <!-- New in V10 - No parameters are required to assign the current date/time.--> {% assign now = 'Now' | Date %} Date Show Details Server: v1.0 Mobile: v1.0 Displays the date given a format string. The string 'Now' can be used for the current date/time. Additional Details Value formatting elements include: Date Elements sd - Returns the culture's standard shortened date format (m/d/yyyy in the US) d - Day of the month 1 - 31. dd - Two digit day of the month 01 - 31. ddd - Abbreviated day of the week (Mon, Tue, etc.) dddd - Full day of the week (Monday, Tuesday, etc.) M - The month, from 1 through 12 MM - The month, from 01 through 12 MMM - The abbreviated name of the month (Jan, Feb, etc.) MMMM - The full name of the month yy - The year, from 00 to 99 yyyy - The year as a four-digit number Time Elements st - Returns the culture's standard shortened time format (h:mm am/pm in the US) h - The hour, using a 12-hour clock from 1 to 12 hh - The hour, using a 12-hour clock from 01 to 12 H - The hour, using a 24-hour clock from 0 to 23 HH - The hour, using a 24-hour clock from 00 to 23 m - The minute, from 0 through 59 mm - The minute, from 00 through 59 s - The second, from 0 through 59 ss - The second, from 00 through 59 tt - The AM/PM designator For even more options see the Microsoft .Net Custom Date and Time Formatting Reference Guide. Example: "Person": { "FirstVisit": "2/13/2011 8am" } Ted's first visit was on {{ Person | Attribute:'FirstVisit' | Date:'dddd, MMMM d, yyyy' }}. Ted's first visit was on Sunday, February 13, 2011. DateAdd Show Details Server: v4.0 Mobile: v1.0 Adds a span of time to a provided date (default is in days). Additional Details By default this filter assumes the amount you pass in is in days. You can also pass in other intervals as a second parameter like: {{ 'Now' | DateAdd:-12,'h' }} This would subtract 12 hours from the current date/time. Valid units are: y - Years v8.0 M - Months v8.0 w - Weeks v8.0 d - Days h - Hours m - Minutes s - Seconds Adding weeks is simply a shorthand for adding by 7 days at a time. Example: "CurrentPerson": { "FirstVisit": "2/14/2011" } Your first visit was {{ CurrentPerson | Attribute:'FirstVisit' }}. Two weeks later would be {{ CurrentPerson | Attribute:'FirstVisit' | DateAdd:14 }}. Your first visit was 2/14/2011. Two weeks later would be 2/28/2011. Note: When adding months and years, if you are going from one month with more days than the target month, the day number will be reduced to fit within the new target month. 5/31/2018 + 1 month = 6/30/2018 2/29/2016 + 1 year = 2/28/2017 DateDiff Show Details Server: v1.0 Mobile: v1.0 Takes two datetimes and returns the difference in the unit you provide. You can provide the value 'Now' for either the start or end date. Additional Details Valid units are: Y - Years M - Months d - Days h - Hours m - Minutes s - Seconds Example: "Person": { "FirstVisit": "2/14/2011 8am", "SecondVisit": "3/18/2011 11:30am" } It was {{ Person.FirstVisit | DateDiff:Person.SecondVisit,'d' }} days between {{ Person.NickName }} first and second visit. It was 32 days between Ted's first and second visit. Note: If the start date is after the end date a negative number will be displayed. DatesFromICal Show Details Server: v4.0 Returns a list of upcoming dates from an iCal string or List of iCal strings. Additional Details This filter has some optional input parameters: The number of occurrences to display (optional): The default is 1. A text value of 'All' can also be used to return all the occurrences (up to one year's worth). enddatetime: (optional) v7.0 if 'enddatetime' is provided, the EndTime property of the iCal's occurrence is returned instead of the StartTime. Example: "EventItemCampuses": { [ { "ContactEmail": "jenny@rocksolidchurchdemo.com", "EventItemSchedules": [ { "Schedule": { ... , "iCalendarContent": "BEGIN:VCALENDAR VERSION:2.0 PRODID:-//ddaysof...", ... , } } ] } ] } {% assign upcomingDates = EventItemSchedules | Select:'Schedule' | Select:'iCalendarContent' | DatesFromICal:2 %} <ul> {% for date in upcomingDates %} <li>{{ date }}</li> {% endfor %} </ul> {% assign upcomingEndDates = EventItemSchedules | Select:'Schedule' | Select:'iCalendarContent' | DatesFromICal:2,'enddatetime' %} <ul> {% for endDate in upcomingEndDates %} <li>{{ endDate }}</li> {% endfor %} </ul> <ul> <li>7/15/2015 7:00:00 PM</li> <li>7/16/2015 7:00:00 PM</li> </ul> <ul> <li>7/15/2015 8:00:00 PM</li> <li>7/16/2015 8:00:00 PM</li> </ul> Note: This is a complex filter. The example above uses a portion of the input from the calendar items lava file. It's only a sample and may need some changes to work correctly. See the CalendarItem.lava file in the themes folders for a working example. DaysFromNow Show Details Server: v4.0 Mobile: v1.0 Returns a humanized string of the number of days from now without concern for time. Additional Details Valid return values are: X days ago yesterday today tomorrow in x days Example: "Person": { "FirstVisit": "2/14/2015 8:00 AM", } Visted {{ Person.FirstVisit | DaysFromNow }}. Visited 14 days ago. DaysInMonth Show Details Server: v7.0 Mobile: v1.0 Returns the number of days in the month you provide. Additional Details There are several options on how to provide the month/year combination to check for. Valid methods include: {{ 'now' | DaysInMonth }} - Get the days in the current month/year. {{ '2/1/2017' | DaysInMonth }} - Get the days in the date provided. {{ '' | DaysInMonth:'02','2016' }} - Get the days based on the month/year provided. Example: None There are {{ 'now' | DaysInMonth }} days in the current month. There are 31 days in the current month. DaysSince Show Details Server: v8.0 Mobile: v1.0 Returns the number of days have past since a given date. Additional Details Example: "Person": { "FullName": "Ted Decker", "AnniversaryDate": '12/23/1995', } {{ Person.NickName }} was married {{ Person | Attribute:'AnniversaryDate' | DaysSince }} days ago. Ted was married 8215 days ago. DaysUntil Show Details Server: v8.0 Mobile: v1.0 Returns the number of days from now. Additional Details Example: "Person": { "FullName": "Ted Decker", "StaffSabatical": '5/10/2020', } {{ Person.NickName }} can take a sabatical in {{ Person | Attribute:'StaffSabatical' | DaysUntil }} days. There are just {{ '12/25/2018' | DaysUntil }} days until Christmas at Rock Solid Church. Ted can take a sabatical in 690 days. There are just 188 days until Christmas at Rock Solid Church. HumanizeDateTime Show Details Server: v1.0 Mobile: v1.0 Compares the provided date/time to the current date/time and returns a human friendly string like 'yesterday' or '2 hours ago'. Additional Details Example: "Person": { "FullName": "Ted Decker", "AnniversaryDate": '12/23/1995', } {{ Person.NickName }} was married {{ Person.AnniversaryDate | HumanizeDateTime }}. Ted was married 18 years ago. Note: Other examples of possible return strings include: "yesterday" "2 hours ago" "4 days ago" "2 weeks ago" "6 months ago' It can even work with future dates: "tomorrow" "2 hours from now" etc. In Rock v4.0 you can optionally add a compare datetime as a parameter HumanizeDateTime:'8/1/2015'. HumanizeTimeSpan Show Details Server: v1.0 Mobile: v1.0 Takes two datetimes and humanizes the difference like '1 day'. Supports 'Now' in either the start or end date. Additional Details Example: "Person": { "FirstVisit": "2/14/2011 8am", "SecondVisit": "3/18/2011 11:30am" } It was {{ Person.FirstVist | HumanizeTimeSpan:Person.SecondVisit }} between {{ Person.NickName }}'s first and second visit. It was 4 weeks between Ted's first and second visit. Note: There is an optional precision value you can apply to the filter to enchance the detail of the description. The default value of precision is 1 which means only the largest time unit is returned. {{ Person.FirstVist | HumanizeTimeSpan:Person.SecondVisit,2 }} 3 - 4 weeks, 4 days 4 - 4 weeks, 4 days, 3 hours 5 - 4 weeks, 4 days, 3 hours, 30 minutes NextDayOfTheWeek Show Details Server: v8.0 Mobile: v1.0 Advances the date to a specific day in the next 7 days. Additional Details Example: "CurrentPerson": { "FirstVisit": "2/9/2011" } {{ CurrentPerson | Attribute:'FirstVisit' | NextDayOfTheWeek:'Friday' }} 2/11/2011 Note: Optional Parameters: includeCurrentDay (default false) - If true, the date's day can match the given day. Example: {{ "5/1/2018" | NextDayOfTheWeek:'Tuesday', true }} would result in "5/1/2018" because it was also a Tuesday. numberOfWeeks (default 1) - use negative numbers to go back a number of weeks. SundayDate Show Details Server: v5.0 Mobile: v1.0 Returns the Sunday date portion (without any time portion) of the date provided. Additional Details Keep in mind that Rock considers Sunday to be the last day of the week. This makes sense when calculating church metrics. The 'Now' keyword can be used in place of a date for the current date. Example: "CurrentPerson": { "FirstVisit": "2/14/2011" } You first visited on the week of {{ CurrentPerson | Attribute:'FirstVisit' | SundayDate }}. You first visited on the week of 2/20/2011. Note: To get the previous Sunday simply pipe the filter through DateAdd. {{ 'Now' | SundayDate | DateAdd:-7 }} ToMidnight Show Details Server: v8.0 Mobile: v1.0 Sets the time to midnight for a specific day. Additional Details Example: "Person": { "FirstVisit": "2/13/2011 8am" } {{ Person | Attribute:'FirstVisit' | ToMidnight }} 2/13/2011 12:00:00 AM