Functions | Chatbot Library
Skip to main content

Functions

These functions are helpers that do not really make differences on Zaroc, these just help us to achieve certain result eficiently.

Feel free (Just in Functions) to add, edit, delete functions as you want.

Date

getAge
  • Put Date time in quotes and in DD-MM-YYYY
$datetime;
$age = getAge($datetime);
getDay
  • Receives a Date, retrieves the day number of the month
$currentDate;
$today = getDay($currentDate);
getFormatDate
  • Receives a Date, a format in string format and outputs that Date in the specified format.
$date;
$formatedDate = getFormatDate($date,'d-m-Y');
addDaysWithDate
  • Receives a number of Days, the specified date, returns the date plus the days added.
$date;
$days = 3;
$newDate = addDaysWithDate($date,$days);
addDaysWithDateSpanish
  • Does the same that the function listed before, just changes the format.
$date;
$days = 3;
$newDate = addDaysWithDateSpanish($date,$days);
getSpanishDays
  • Receives a Date and returns a day in String and Spanish Language.
$date;
$dia = getSpanishDays($date);
getNextDays
  • Receives a number of days, returns the current day plus the number of days.
$number = 5;
$newDay = getNextDays($number);
getNextMonths
  • Receives a number of months, returns the current month plus the number of days.
$number;
$newMonth = getNextMonths($number);
getNextTimes
  • Receives a number of days, returns the current date plus the number of days.
$number = 4;
$newDate = getNextTimes($number);
getCompositeTime
  • Receives a Day and returns in a specific format.
$day;
$newtime = getCompositeTime($day);
changeDateOrder
  • String Example $3-$2-$1 to DD-MM-YYYY
$originalDate;
$order = 'DD-MM-YYYY';
$newDate = changeDateOrder($originalDate,$order);
getIntegerNextDays
  • Returns a single day with plus numbers of days added
$number = 4;
$newDay = getIntegerNextDays($number);
getSpanishNextDays
  • Returns a complete format of Spanish Date
$number = 5;
$newDate = getSpanishNextDays($number);
getSpanishCompositeTime
  • Get composite Time in Spanish
$day;
$newDate = getSpanishCompositeTime($day);
tsToDateTime
  • Converts TS format to a Y-m-d H:i A format
$ts;
$dateTime = tsToDateTime($ts)

Text

id

  • Returns a little Random ID
$id = id();

id2

  • Returns a stronger Random ID
$id = id2();

createSpan

  • Help us to create a Span, this span works adding Styles to text on webBlocks
$text = array("Title");
$properties = array("style='color:red';");
$span = createSpan($text,$properties);

endsWith

  • Checks if a String ends with an specific Letter
$result =  endsWith($haystack, $needle);

startsWith

  • Checks if a String starts with specific string
$string = "hello world";
$startString = "he";

$result = startsWith ($string, $startString);

reduce

  • Removes blank spaces
$text = "Hey There how are you   ";

$newText = reduce($text);

lower

  • Changes to lowerCase
$text = "HEy THERE";

$newText = lower($text);

reduceLower

  • Chantes to lowerCase and removes blank spaces
$text = "HEy THERE";

$newText = reduceLower($text);

titleAdjust

  • Removes blank spaces and changes to uppercase
$text = "HEy THERE";

$title = titleAdjust($text);
  • Creates a WhatsAppLink with a Prefered Opening Text
$phone = array("XXXXXX");
$text = array("Hey there, welcome to my whatsapp chat");

$wsLink = whatsAppLink($text,$phone)

textToUrlEncode

  • Changes the Text to a Url Format
$text = array("Text ready to be encoded");

$nexText = textToUrlEncode($text);

Mail

prepareEmail

  • Help us to prepare a Email (Change its variables and more).
$variables = array(
'variable1' => 'value1',
'variable2' => 'value2'
);

$emailFileUrl = array("./../email/testEmail.html");

$email = prepareEmail($variables, $emailFileUrl);

Api

getJSONVariable

  • Help us to retrieve information from a JSON
$variableName = array("color");
$jsonBody;

$variable = getJsonVariable($jsonBody, $variableName);

adaptJSON

  • Adapts Json.Stringify format to a readable format to PHP
$jsonBody = '" { "format" : "nice" } "';

$newJSON = adaptJson($jsonBody);

openWeatherAPI

  • Help us consume openWeatherAPI
$apiKey = array("XXXXXXXXXXXXXXXXXXXXXXXX");
$country = array("-MX");
$location = array("Mexico City");

$url = openWeatherAPI($apiKey,$country,$location);

internationalNewsAPI

  • Help us consume internationalNewsAPI
$apiKey = array("XXXXXXXXXXXXXXXXXXXXXXXX");
$category = array("Health");
$country = array("-MX");
$page = array("1");

$url = internationalNewsApi($apiKey,$category,$country,$page);