Convert Date & Time - CodelessBot

What Does This Plugin Do?

BETA
 
This plugin will convert a date and time by changing its format and/or adding time (e.g. years, months, weeks, days, etc..) to the date.
 

Level of Difficulty: Easy-Medium

Compatibility: Chatfuel, ManyChat

 
Plugin Request URL
  • Chatfuel: https://api.codelessbot.com/v1/chatfuel/datetime/convert?accesskey={{cbot_accesskey}}&secretkey={{cbot_secretkey}}
  • ManyChat: https://api.codelessbot.com/v1/manychat/datetime/convert?accesskey=YOURACCESSKEY&secretkey=YOURACCESSKEY

Example Use Cases

Include Date in Coupon or Certificate

Want to include a perfectly formatted date for a coupon or certificate? Just use this plugin to change the format to your liking!

r

Expiration Date for Offer

Want to let users know that the offer is only good for a certain time period? Just use this plugin to add a specific time to a date.

Convert & Translate

Convert the date from one language and timezone…into a different language and timezone!

How-To Setup the Plugin

Follow the 3 Simple Steps...or Login to CodelessBot to access the Plugin Wizard!

Step 1. Download & Install the Quick-Start Plugin Template

Login to CodelessBot, navigate to Templates on the sidebar and download the Quick-Start Template. Follow the prompt to install the Template. Next, you'll need to create a copy of the template for this specific plugin. See and follow the instructions below.

(If you've already install the Quick Start Template and created a copy of the plugin template - skip this step!

Chatfuel Instructions

a. From your Chatfuel dashboard, open the new bot called "JSON API Tutorial & CodelessBot Template" 

b. Find the group containing the name of this plugin.

c. Click on the arrow next to the plugin name to clone this group and blocks from the template into your own Chatfuel Bot.

d. Navigate back to the Chatfuel Dashboard

e. Open your Bot and find the new plugin group that you just cloned. 

f. Open the new Plugin block and enter in your CodelessBot access key and secret key.

Tip: Rename the plugin block to something more meaningful. For more details, refer to the Getting Started Guide.

ManyChat Instructions

After you download and installed the Quick Start Template...

  1. From the ManyChat sidebar, click on the Flows"
  2. Open the folder "CodelessBot Templates"
  3. Find the flow containing the name of this plugin. 
  4. Create a copy by click on the three dots icon on the right
  5. Then click on duplicate
  6. Feel free to rename this new flow and move it to a different folder
  7. Open up the flow and click on the "Starting Step" to modify the information you'll be sending to CodelessBot

For more details, refer to the Getting Started Guide.

Step 2. Send information to CodelessBot

To quickly do this, use the Plugin Wizard to answer a few questions. It'll then generate the code with the information below for you to copy and paste into your bot.

cbot_date

The date you wish to convert and/or format.

More Detail

Provide any date and time you want to convert as text.

You can also use the special keyword “now” for current date and time.

cbot_format_in (May be required)

The format of your date.  It is required unless you used “now” for cbot_date.

More Detail

Use the CodelessBot plugin wizard for commonly used formats or use any combination below:

YYYY – Four digit year (e.g. 2019, 2020)
    YY – Double digit year (e.g. 19, 20)

    M – Single digit month (e.g. 1, 2, … 12)
  MM – Double digit month (e.g. 01, 02, … 12)
 MMM – Abbreviated month (e.g. Jan, Feb, … Dec)
MMMM – Month (e.g. January, February, …. December)

     D – Single digit day of month (e.g. 1, 2, … 31)
  DD – Double digit day of month (e.g. 01, 02, … 31)
 ddd – Abbreviated day of week (e.g. Mon, Tues, … Sun)
 dddd – Day of week (e.g. Monday, Tuesday, … Sunday)

     h – Single digit hour of day (e.g. 1, 2, … 12)
     H – Single digit hour of the day, military time (e.g. 0, 1, … 23)
    m – Single digit minute of the hour (e.g. 1, 2, … 59)
  mm – Double digit minute of the hour (e.g. 01, 02, … 59)
    s – Single digit second of the minute (e.g. 1, 2, … 59)
  ss – Double digit second of the minute (e.g. 01, 02, … 59)

    a – Lowercase AM/PM indicator
    A – Uppercase AM/PM indicator

   z – Abbreviated timezone
   Z – Timezone offset (e.g. -07:00, -08:00)  

cbot_format_out

The format you want to convert your date to.

More Detail

Use the CodelessBot plugin wizard for commonly used formats or use any combination below:

YYYY – Four digit year (e.g. 2019, 2020)
    YY – Double digit year (e.g. 19, 20)

    M – Single digit month (e.g. 1, 2, … 12)
  MM – Double digit month (e.g. 01, 02, … 12)
 MMM – Abbreviated month (e.g. Jan, Feb, … Dec)
MMMM – Month (e.g. January, February, …. December)

     D – Single digit day of month (e.g. 1, 2, … 31)
  DD – Double digit day of month (e.g. 01, 02, … 31)
 ddd – Abbreviated day of week (e.g. Mon, Tues, … Sun)
 dddd – Day of week (e.g. Monday, Tuesday, … Sunday)

     h – Single digit hour of day (e.g. 1, 2, … 12)
     H – Single digit hour of the day, military time (e.g. 0, 1, … 23)
    m – Single digit minute of the hour (e.g. 1, 2, … 59)
  mm – Double digit minute of the hour (e.g. 01, 02, … 59)
    s – Single digit second of the minute (e.g. 1, 2, … 59)
  ss – Double digit second of the minute (e.g. 01, 02, … 59)

    a – Lowercase AM/PM indicator
    A – Uppercase AM/PM indicator

   z – Abbreviated timezone
   Z – Timezone offset (e.g. -07:00, -08:00)  

cbot_timezone_in (Optional)

The timezone of your date.

More Detail

Defaults to same value as “cbot_timezone_out” if it’s not provided.  Use the CodelessBot plugin wizard to select a valid timezone.

cbot_locale_in (Optional)

The language of your date.

More Detail

Defaults to same locale as “cbot_locale_in” if not provided. Valid options are en-US (English US), en-GB (English UK),  fr (French), de (German), it (Italian), pt-BR (Portuguese Brazil), pt-PT (Portuguese Portugal), es (Spanish), vi (Vietnamese).

cbot_years (Optional)

The number of years to add to your date.

More Detail

Valid values are -100 to 100.

cbot_months (Optional)

The number of months to add to your date.

More Detail

Valid values are -120 to 120.

cbot_hours (Optional)

The number of hours to add to your date.

More Detail

Valid values are -8760 to 8760.

cbot_seconds (Optional)

The number of seconds to add to your date.

More Detail

Valid values are -31536000 to 31536000.

cbot_timezone_out (Optional)

The timezone you want to convert your date to.

More Detail

Defaults to “UTC” if not provided.  Use the CodelessBot plugin wizard to select a valid timezone.

cbot_locale_out (Optional)

The language you want to convert your date to.

More Detail

Defaults to “en-US” if not provided. 

Valid options are en-US (English US), en-GB (English UK),  fr (French), de (German), it (Italian), pt-BR (Portuguese Brazil), pt-PT (Portuguese Portugal), es (Spanish), vi (Vietnamese).

cbot_weeks (Optional)

The number of weeks to add to your date.

More Detail

Valid values are -520 to 520.

cbot_days (Optional)

The number of days to add to your date.

More Detail

Valid values are -3650 to 3650.

cbot_minutes (Optional)

The number of minutes to add to your date.

More Detail

Valid values are -525600 to 525600.

cbot_order (Optional)

The order to add the units of time. (eg. years, months, day…etc)

More Detail

Default value: years, months, weeks, days, hours, minutes, seconds

When adding units of time to a date, the exact order in which various units are added will matter due to changes in daylight savings and leap years.

If you provide a partial list like “weeks, minutes” then the partial list will be merged with default order.  Weeks and minutes will be added first, respectively, and then all remaining units of time (years, months, days, hours, seconds) will be added using default order.

Chatfuel Instructions
  1. In this plugin block, scroll down to the "JSON API" card
  2. Copy and paste the code from the Plugin Wizard into the textbox. (Or you can enter the correct value by referring to the descriptions above.)

Tip: Make sure the "Send as" is set to JSON. Not URL encoded or Full JSON Profile.

ManyChat Instructions

a. Click over to the "Body" tab in this external request 

b. Next, copy and paste the code from the Plugin Wizard into the "Request Body". (Or you can enter the correct value by referring to the descriptions above.)

c. If there are any "Replace With placeholder" in the code, you'll need to replace them with the correct matching custom field by clicking on "Add a Variable".

d. To check if you set this up correctly, click on "Test the Request" on the right and you should get a success "200 OK" response

e. Click on the blue "Save" button

Step 3. CodelessBot will reply with the "answer"

CodelessBot will reply back with the following information:

cbot_rsp

A text representing your formatted date and time.

More Detail

e.g. January 1, 2019

Chatfuel Instructions

After the JSON API card, you can add additional Chatfuel cards to:

  1. Send a message to the user with the result
  2. Add a new card "Go To Block" with a condition to redirect users to a different blocks depending on the result

Note: These are just some ideas. You are not limited by the 2 ideas above.

ManyChat Instructions

Finally, to save and make use of the results, you'll need to save the answer(s) from the CodelessBot to ManyChat custom field(s). To do this:

a. Click over to the "Response mapping" tab.

b. All the answer(s) are already listed for you under the first column "JSONPath". (For more detail about each one, see description above).

For each answer, select the ManyChat custom field you want to use to store the value from CodelessBot. Feel free to delete any that you don't need.

c. Click on "Save" when you're done. After this external request step, you can add a next step where you're:

  • Sending a message to share the results with users
  • Add a new Condition step to redirect users to a different step or flow depending on the result

More Information

FAQs

1. Does this plugin take into account daylight savings?

If the city you select in the timezone dropdown observes daylight savings…then yes, this plugin will take daylight savings into account!

2. Why does the order of the to add the units of time matter?

To best explain why it matters, here’s an example. Suppose you want to add some time to the date January 29. More specifically, you want to add 1 month and 1 day. (The year of this date for the purposes of this example doesn’t matter)

Scenario A (Add 1 month and then 1 day)

  • If you add 1 month, you get the date February 28th
  • Then when you add 1 day, you’ll get the date March 1st
  • End Result: March 1st

Scenario B (Add 1 day and then 1 month)

  • If you add 1 day, you get the date January 30th
  • Then when you add 1 month, you’ll get the date February 28th
  • End Result: February 28th

The order might make a difference when you’re adding two units of time. The order doesn’t matter if you’re just adding 1 unit of time.

3. Can this plugin convert a date and time from one timezone to another?

Yes. It does have that ability. You’ll just need to provide it with the input and output timezones.

4. Can this plugin convert a date and time from one language to another?

Yes. It does have that ability. You’ll need to provide it with the input and output language/locale.

5. Can this plugin translate the date from one language to another?

Yes! It can format the date and time, for example, from 05/15/2020 to May 15, 2020.

It can also reformat the month “5” to:

  • “May” if English US is selected
  • “mai” if French is selected
  • “mayo” if Spanish is selected

6. What languages are supported?

We currently support up to 9 locales:

  • English UK
  • English US
  • French
  • German
  • Italian
  • Portuguese Brazil
  • Portuguese Portugal
  • Spanish
  • Vietnamese

If you’d like to submit a request for a specific language, just <a href=”#message”>send us a message<a/>.

 

Enhance Your Bot with CodelessBot

CodelessBot plans start from $18/month