Login +

Reference Guide / SLS_Date

SLS_Date1 is a class for dates handling.


At Controller level, you access it directly byinstantiating the class:

$date = new SLS_Date(date("Y-m-d H:i:s"));

Class methods

- To get a date formatted according to your criteria, use the getDate() function:

$date->getDate("MONTH_LITTERAL", [$predefined=true]);

The possible value of the parameter of this function are:

Pattern Description Default value
'TIME' Part time 'H:i:s'
'FULL_TIME' Part date + time 'Y-m-d H:i:s'
'DATE' Part date 'Y-m-d'
'MONTH_LITTERAL' Part date with litteral month 'd F Y'
'FULL_LITTERAL' Part date with litteral day + month 'l d F Y'
'FULL_LITTERAL_TIME' Part date + time with litteral day + month 'l d F Y H:i:s'
'MONTH_LITTERAL_TIME' Part date + time with litteral month 'd F Y H:i:s'

Their contents depend on the patterns selected during installation.

If you want a custom pattern, just pass your php date() function pattern and set the second parameter to false :

$date->getDate("G:m A - j M Y",false)

- To get a specific part of this date, use the __get() function:


- To get the difference of time between the current date and the date passed to the constructor, use the getDiff() function:


Conversion of date formats

You have 6 static methods to convert dates :



  1. SLS_Date - Tool SLS_Date - Dates Handling