{"id":454,"date":"2022-09-05T14:01:36","date_gmt":"2022-09-05T12:01:36","guid":{"rendered":"https:\/\/support.botnation.ai\/date-variables-and-functions\/"},"modified":"2026-02-25T13:04:40","modified_gmt":"2026-02-25T12:04:40","slug":"date-variables-and-functions","status":"publish","type":"support","link":"https:\/\/botnation.ai\/en\/support\/date-variables-and-functions\/","title":{"rendered":"Date: variables and functions"},"content":{"rendered":"<p>Everything you need to know to display and manipulate dates and schedules with bn_date<\/p>\n\n\n\n<p>Here is how to easily manipulate the date variables to customize your chatbots even more.<\/p>\n\n\n\n<p>These \u201cmagic\u201d variables are processed dynamically in the display and in the conditions.<\/p>\n\n\n\n<p>It becomes very easy to say \u201cgood evening\u201d instead of \u201cgood morning\u201d, to answer that the physical store is closed this Sunday, but will be open next Tuesday etc\u2026<br><\/p>\n\n\n\n\n\n<p><br><strong>Here is the list of \u201cmagic\u201d variables reserved for dates:<\/strong><\/p>\n\n\n\n<p>As a preamble, let\u2019s clarify something you often ask us! We count these 2 types of variables:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>bn_date<\/li><li>calendar_day<\/li><\/ul>\n\n\n\n<p>Each has its own purpose and should not be confused.<\/p>\n\n\n\n<p>In the case that interests us here, the system variables linked to dates, the type <strong>{{BN_DATE}}<\/strong> represents variables that call for information that the system transmits to us. This will observe the following mechanics:<\/p>\n\n\n\n<p>User: \u201cWhat time is it please\u201d?<\/p>\n\n\n\n<p>Chatbot: \u201c14:08\u201d<\/p>\n\n\n\n<p>Obviously, <a href=\"https:\/\/botnation.ai\/que-faire-quand-les-utilisateurs-posent-plusieurs-questions-a-la-fois\/\">when the user asks the question<\/a> again 10 minutes later, the information will have evolved and the chatbot will answer \u201c2:18 pm\u201d and so on.<\/p>\n\n\n\n<p>If you use the variable in this way: {{bn_date_TodayYMDT}}, the chatbot will display the date in \u201ccomputer\u201d (database) + time format: \u201c2020\/06\/27 21:10\u201d<\/p>\n\n\n\n<p>They are dynamic in short!<\/p>\n\n\n\n<p>Now that you understand the subtlety, we invite you to check out the rest \ud83d\ude09<\/p>\n\n\n\n<p>{{bn_date_minute}}<br>Minute (01\u202660)<\/p>\n\n\n\n<p>{{bn_date_hour}}<br>Hour (01\u202624)<\/p>\n\n\n\n<p>{{bn_date_day}}<br>Day (01\u202631)<\/p>\n\n\n\n<p>{{bn_date_month}}<br>Month (01\u202612)<\/p>\n\n\n\n<p>{{bn_date_year}}<br>Year (1900\u2026)<\/p>\n\n\n\n<p>{{bn_date_Yday}}<br>Day of the year (1\u2026365)<\/p>\n\n\n\n<p>{{bn_date_Wday}}<br>Day of the week. (1\u20267) 1 = Sunday, 2 = Monday\u2026 7 = Saturday<br><br>{{bn_date_WdayTxt}}<br>Day of the week, in text. (monday, tuesday.. or monday, tuesday\u2026)<\/p>\n\n\n\n<p>{{bn_date_Period}}<br>Time of day. Useful for personalizing the reception!<\/p>\n\n\n\n<p>1 = morning<br>2 = afternoon<br>3 = evening<br>4 = night<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-51.png.webp\" alt=\"\" class=\"wp-image-445\"><figcaption>Design<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"264\" height=\"92\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-52.png.webp\" alt=\"\" class=\"wp-image-447\"><figcaption>Result<\/figcaption><\/figure>\n<\/div>\n\n\n<p>{{bn_date_TodayYMD}}<br>Displays the date in \u201ccomputer\u201d (database) format: 2018\/04\/28<\/p>\n\n\n\n<p>{{bn_date_TodayYMDT}}<br>Displays the date in \u201ccomputer\u201d (database) format + time: 2018\/04\/28 11:18<\/p>\n\n\n\n<p>{{bn_date_TodayMDY}}<br>Displays the date in US format: 04\/28\/2018<\/p>\n\n\n\n<p>{{bn_date_TodayMDY}}<br>Displays the date in US format without the year: 04\/28<\/p>\n\n\n\n<p>{{bn_date_TodayMDYT}}<br>Displays the date in US format + time: 04\/28\/2018 11:18<\/p>\n\n\n\n<p>{{bn_date_TodayMDYT}}<br>Displays the date in US format + time without the year: 04\/28 11:18<\/p>\n\n\n\n<p>{{bn_date_TodayMDYTXT}}<br>Displays the date in US text format: Friday May 4 2018<\/p>\n\n\n\n<p>{{bn_date_TodayMDTXT}}<br>Displays the date in US text format without the year: Friday May 4<\/p>\n\n\n\n<p>{{bn_date_TodayDMY}}<br>Displays the date in EU format: 28\/04\/2018<\/p>\n\n\n\n<p>{{bn_date_TodayDM}}<br>Displays the date in EU format without the year : 28\/04<\/p>\n\n\n\n<p>{{bn_date_TodayDMYT}}<br>Displays the date in EU format: 28\/04\/2018 11:18<\/p>\n\n\n\n<p>{{bn_date_TodayDMT}}<br>Displays the date in EU format without the year : 28\/04 11:18<\/p>\n\n\n\n<p>{{bn_date_TodayDMYTXT}}<br>Displays the date in EU text format: Friday, May 4, 2018<\/p>\n\n\n\n<p>{{bn_date_TodayDMTXT}}<br>Displays the date in EU text format without the year: Friday May 4th<\/p>\n\n\n\n<p>{{bn_date_timestamp}}<br>Gives the current timestamp, i.e. the number of seconds elapsed since January 1, 1970.<br>It is useful to measure the time spent between 2 events.<\/p>\n\n\n\n<p>We take into account the user\u2019s TimeZone. Concretely, at the same time, a chatbot can now display \u201cBonjour\u201d to a French person and \u201cBonne nuit\u201d to a Japanese person by using the magic variable {{bn_date_Period}} .<\/p>\n\n\n\n<p><strong>The dates can also be manipulated with options!<\/strong><\/p>\n\n\n\n<p>_-3_min<br>_+60_sec<br>_+1_hour<br>_-2_day<br>7 week<br>etc\u2026<\/p>\n\n\n\n<p><strong>Examples:<\/strong><br>{{bn_date_TodayDMY_+2_week}}<\/p>\n\n\n\n<p>Will return the date that it will be exactly in 2 weeks.<\/p>\n\n\n\n<p>This works on all previous functions, such as :<br>{{bn_date_TodayDMY_+25_day}}  <\/p>\n\n\n\n<p>Which will return the date to + 25 days.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"339\" height=\"190\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-53.png.webp\" alt=\"\" class=\"wp-image-449\" srcset=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-53.png 339w, https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-53-300x168.png 300w\" sizes=\"(max-width: 339px) 100vw, 339px\" \/><figcaption>Design<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"612\" height=\"56\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-54.png.webp\" alt=\"\" class=\"wp-image-451\" srcset=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-54.png 612w, https:\/\/botnation.ai\/wp-content\/uploads\/2022\/09\/image-54-300x27.png 300w\" sizes=\"(max-width: 612px) 100vw, 612px\" \/><figcaption>Result<\/figcaption><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"-important-\">!! IMPORTANT!!!  <\/h3>\n\n\n\n<p>It is highly recommended to use the local (country) timezone of the Chatbot instead of the user\u2019s timezone by adding <strong>_local <\/strong>before the period if your schedule should not change depending on the user\u2019s location, for example for a physical store.<\/p>\n\n\n\n<p><strong>Examples:<\/strong><br>{{bn_date_hour}} -&gt; User time (Tokyo as Japanese)<br>{{bn_date_local_hour}} -&gt; Time in the bot\u2019s parameterized area (Paris for example)<\/p>\n\n\n","protected":false},"featured_media":0,"template":"","meta":{"_acf_changed":false},"categorie-support":[194],"class_list":["post-454","support","type-support","status-publish","hentry","categorie-support-features"],"acf":[],"_links":{"self":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support\/454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support"}],"about":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/types\/support"}],"wp:attachment":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/media?parent=454"}],"wp:term":[{"taxonomy":"categorie-support","embeddable":true,"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/categorie-support?post=454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}