Views: 7413
Last Modified: 08.10.2024

  Date conversion to English language

To print the date, use the function date date - Formats system date/time output

. The presented example uses the parameter F - full month name. List of all parameters can be found in PHP documentation.

Current month - {{=date('F',{=System:Date})}}

Result is the notification type Current month - April.

To get the month name in English, create Match list for month names. Print a workflow of List variable type:

Indicate the key - month number, with value next (month name in English) inside the value variants in square brackets.

Add the action Variable update to the workflow template in front of the social network message with specified function {{=date('n')}}, where n - month sequence number without leading zero (from PHP documentation).

Update the printed message text for your Variable1 variable in the Social Network action:

Current month - {=Variable:Variable1 > printable}

Result:

As a result, weekdays and other dates can be printed.

  Relative date format

Assignment: print the date - Friday next week. it can be done via the strtotime function and relative PHP format.

Create new variable Date and use the action Set variables, as in the example above. Indicate the value ='next week friday':

Print the Date variable in social network message text.

Next Friday - {=Variable:Variable2 > printable}

Result

  Adding N days from the parameter

First, a simple example: adding to current date the precise number of days.

You will need the function dateadd:

Current date + 2 days: {{=dateadd({=System:Date}, '2d')}} // add 2 days to the current date

Now, add a specific number of days, stored in the workflow parameter:

Current date + N days: {{=dateadd({=System:Date}, {=Template:Parameter1} & 'd')}} // add days from parameter to the current date

Important! To indicate correctly number of days from the parameter, use the concatenation operator that returns string/connection of left and right argument.

Result (10 value is specified in the parameter upon workflow launch):

0


Courses developed by Bitrix24