{"id":3345,"date":"2022-05-11T03:49:25","date_gmt":"2022-05-11T03:49:25","guid":{"rendered":"https:\/\/www.greminders.com\/articles\/?p=3345"},"modified":"2025-11-21T02:28:14","modified_gmt":"2025-11-21T02:28:14","slug":"advanced-date-template-logic","status":"publish","type":"post","link":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/","title":{"rendered":"Advanced Date Template Logic"},"content":{"rendered":"\n<p>GReminders is a great way to automate SMS, Email or Phone reminder or follow up notifications to your Clients.   The system also has a <a href=\"https:\/\/www.greminders.com\/articles\/getting-fancy-with-templates\/\">very advanced Content Template<\/a> mechanism built on the <a href=\"https:\/\/shopify.github.io\/liquid\/\">Liquid Templating Library<\/a>.  (Thank you Shopify, they were the creators of the initial library, we all build on the shoulders of Giants)<\/p>\n\n\n\n<p>Recently we had a customer ask if they could send a Reschedule Link to their customers but ONLY if the appointment was more than 6 months into the future.   (this was a good opportunity to show everyone the power of the template system)<\/p>\n\n\n\n<p>Content Templates support light coding, and thus also support concepts such as variables and basic if then logic.<\/p>\n\n\n\n<p>So first we need to convert date\/times into &#8220;numbers&#8221; so we can do some basic greater than\/less than operations.<\/p>\n\n\n\n<p>In the date\/time world there is such a thing called UNIX Epoch Time which transforms a point in time into a number, the number is the number of seconds from the date Jan 1, 1970.   If you haven&#8217;t heard of that its ok, its a bit strange but computers prefer numbers to dates\/times and it works and is commonly used in coding.    <\/p>\n\n\n\n<p>So what we want to do here is create 2 variables.   The first is converting the existing start date\/time of the event into a number like so:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{% assign event_start_date = event.date_time_advanced | date: '%s' %}<\/pre>\n\n\n\n<p>What this does specifically is sets the variable &#8220;<meta charset=\"utf-8\">event_start_date&#8221; to a number using our GReminders variable of &#8220;event.date_time_advanced&#8221; and putting it through the date function where %s converts it to a number.<\/p>\n\n\n\n<p>Next, we want to create another variable that is 6 months away from today like so:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{% assign future_date = 'now' | date: '%s' | plus: 15768000 %}<\/pre>\n\n\n\n<p>This sets the variable of &#8220;future_date&#8221; equal to &#8220;now&#8221; (which is literally right now) converts it to a number (using the date function like above) and then ADDING &#8220;plus&#8221; 6 months worth of seconds (so 60 seconds * 60 minutes * 24 hours * 182 days) = 1576800   (1576800 seconds = 6 months)<\/p>\n\n\n\n<p>Now we have 2 numbers in 2 variables.   From here it is very easy to compute.   <\/p>\n\n\n\n<p>If we simply wanted to output the numbers we could do this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Start Date: {{event_start_date}}\nFuture Date: {{future_date}}<\/pre>\n\n\n\n<p>But we want to do something a bit more useful so we can do something like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{% if event_start_date &gt; future_date %}\nAllow client to Reschedule\n{% else %}\nDont allow client to reschedule\n{% endif %}<\/pre>\n\n\n\n<p>Putting it all together:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{% assign future_date = 'now' | date: '%s' | plus: 15768000 %}\n{% assign event_start_date = event.date_time_advanced | date: '%s' %}\nReminder, you have an appointment with {{user.firstname}} {{user.lastname}} at {{event.time}} on {{event.date}}.\n{% if event_start_date &gt; future_date %}To Reschedule please go here: {{event.reschedulelink}}{% endif %}<\/pre>\n\n\n\n<p>Outputs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Reminder, you have an appointment with Michael Scott at 3:30pm on Tuesday Dec 20.<br>To Reschedule please go here: https:\/\/greminders.com\/r\/xxxxxx<\/pre>\n\n\n\n<p>Since Dec 20 is more than 6 months away (we are writing this on May 10), the output will show the reschedule link.  If not it won&#8217;t show the last sentence.   <\/p>\n\n\n\n<p>Yes, we know code can be a bit intimidating, but give it a try if you have some more advanced scenarios you want to try out.  <\/p>\n\n\n\n<p>Can&#8217;t figure it out?  No problem, just reach out to support@greminders.com and we will help you.<\/p>\n\n\n\n<p>Happy Scheduling.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GReminders is a great way to automate SMS, Email or Phone reminder or follow up notifications to your Clients. The system also has a very advanced Content Template mechanism built on the Liquid Templating Library. (Thank you Shopify, they were the creators of the initial library, we all build on the shoulders of Giants) Recently [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3348,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[90],"tags":[],"class_list":["post-3345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-criteria"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Advanced Date Template Logic - End to End Meeting Management Platform - SMS Reminders - AI Notetaker<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Advanced Date Template Logic - End to End Meeting Management Platform - SMS Reminders - AI Notetaker\" \/>\n<meta property=\"og:description\" content=\"GReminders is a great way to automate SMS, Email or Phone reminder or follow up notifications to your Clients. The system also has a very advanced Content Template mechanism built on the Liquid Templating Library. (Thank you Shopify, they were the creators of the initial library, we all build on the shoulders of Giants) Recently [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/\" \/>\n<meta property=\"og:site_name\" content=\"End to End Meeting Management Platform - SMS Reminders - AI Notetaker\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/greminders\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-11T03:49:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-21T02:28:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1186\" \/>\n\t<meta property=\"og:image:height\" content=\"617\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sarah Mitchell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sarah Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/\",\"url\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/\",\"name\":\"Advanced Date Template Logic - End to End Meeting Management Platform - SMS Reminders - AI Notetaker\",\"isPartOf\":{\"@id\":\"https:\/\/www.greminders.com\/articles\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg\",\"datePublished\":\"2022-05-11T03:49:25+00:00\",\"dateModified\":\"2025-11-21T02:28:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.greminders.com\/articles\/#\/schema\/person\/66d470bd275ecb9976129c8fd4f37b5c\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#primaryimage\",\"url\":\"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg\",\"contentUrl\":\"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg\",\"width\":1186,\"height\":617,\"caption\":\"SMS Reminder Template Logic\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greminders.com\/articles\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Advanced Date Template Logic\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.greminders.com\/articles\/#website\",\"url\":\"https:\/\/www.greminders.com\/articles\/\",\"name\":\"End to End Meeting Management Platform - SMS Reminders - AI Notetaker\",\"description\":\"GReminders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.greminders.com\/articles\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.greminders.com\/articles\/#\/schema\/person\/66d470bd275ecb9976129c8fd4f37b5c\",\"name\":\"Sarah Mitchell\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greminders.com\/articles\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/73447d573800be149535f95a3b5b4a42?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/73447d573800be149535f95a3b5b4a42?s=96&d=mm&r=g\",\"caption\":\"Sarah Mitchell\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Advanced Date Template Logic - End to End Meeting Management Platform - SMS Reminders - AI Notetaker","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/","og_locale":"en_US","og_type":"article","og_title":"Advanced Date Template Logic - End to End Meeting Management Platform - SMS Reminders - AI Notetaker","og_description":"GReminders is a great way to automate SMS, Email or Phone reminder or follow up notifications to your Clients. The system also has a very advanced Content Template mechanism built on the Liquid Templating Library. (Thank you Shopify, they were the creators of the initial library, we all build on the shoulders of Giants) Recently [&hellip;]","og_url":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/","og_site_name":"End to End Meeting Management Platform - SMS Reminders - AI Notetaker","article_publisher":"https:\/\/www.facebook.com\/greminders\/","article_published_time":"2022-05-11T03:49:25+00:00","article_modified_time":"2025-11-21T02:28:14+00:00","og_image":[{"width":1186,"height":617,"url":"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg","type":"image\/jpeg"}],"author":"Sarah Mitchell","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sarah Mitchell","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/","url":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/","name":"Advanced Date Template Logic - End to End Meeting Management Platform - SMS Reminders - AI Notetaker","isPartOf":{"@id":"https:\/\/www.greminders.com\/articles\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#primaryimage"},"image":{"@id":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#primaryimage"},"thumbnailUrl":"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg","datePublished":"2022-05-11T03:49:25+00:00","dateModified":"2025-11-21T02:28:14+00:00","author":{"@id":"https:\/\/www.greminders.com\/articles\/#\/schema\/person\/66d470bd275ecb9976129c8fd4f37b5c"},"breadcrumb":{"@id":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#primaryimage","url":"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg","contentUrl":"https:\/\/www.greminders.com\/articles\/wp-content\/uploads\/2022\/05\/date_template_logic.jpg","width":1186,"height":617,"caption":"SMS Reminder Template Logic"},{"@type":"BreadcrumbList","@id":"https:\/\/www.greminders.com\/articles\/advanced-date-template-logic\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greminders.com\/articles\/"},{"@type":"ListItem","position":2,"name":"Advanced Date Template Logic"}]},{"@type":"WebSite","@id":"https:\/\/www.greminders.com\/articles\/#website","url":"https:\/\/www.greminders.com\/articles\/","name":"End to End Meeting Management Platform - SMS Reminders - AI Notetaker","description":"GReminders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.greminders.com\/articles\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.greminders.com\/articles\/#\/schema\/person\/66d470bd275ecb9976129c8fd4f37b5c","name":"Sarah Mitchell","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greminders.com\/articles\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/73447d573800be149535f95a3b5b4a42?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/73447d573800be149535f95a3b5b4a42?s=96&d=mm&r=g","caption":"Sarah Mitchell"}}]}},"_links":{"self":[{"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3345"}],"collection":[{"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3345"}],"version-history":[{"count":6,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3345\/revisions"}],"predecessor-version":[{"id":7412,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3345\/revisions\/7412"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=\/wp\/v2\/media\/3348"}],"wp:attachment":[{"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greminders.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}