DataTables PHP 3.1.0

Format
in package

Formatter methods for the DataTables Editor.

All methods in this class are static with common inputs and returns.

Table of Contents

Constants

DATE_EPOCH  = 'U'
Date format: 1331251200. jQuery UI equivalent format: @
DATE_ISO_1036  = 'D, j M y'
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
DATE_ISO_1123  = 'D, j M Y'
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
DATE_ISO_2822  = 'D, j M Y'
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
DATE_ISO_822  = 'D, j M y'
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
DATE_ISO_850  = 'l, d-M-y'
Date format: Friday, 09-Mar-12. jQuery UI equivalent format: DD, dd-M-y
DATE_ISO_8601  = 'Y-m-d'
Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd
DATE_TIMESTAMP  = 'U'
Date format: 1331251200. jQuery UI equivalent format: @
DATE_USA  = 'm-d-Y'
Date format: March-. jQuery UI equivalent format: D, d M yy

Methods

dateFormatToSql()  : string
Convert from a format given by the options parameter to a format that SQL servers will recognise as a date.
dateSqlToFormat()  : string
Convert from SQL date / date time format to a format given by the options parameter.
datetime()  : string
Convert from one date time format to another.
explode()  : string
Convert a string of values into an array for use with checkboxes.
fromDecimalChar()  : string
Convert a number from using any character other than a period (dot) to one which does use a period. This is useful for allowing numeric user input in regions where a comma is used as the decimal character. Use with a set formatter.
ifEmpty()  : string
Formatter that can be used to specify what value should be used if an empty value is submitted by the client-side (e.g. null, 0, 'Not set', etc).
implode()  : string
Convert an array of values from a checkbox into a string which can be used to store in a text field in a database.
nullEmpty()  : string
Convert an empty string to `null`. Null values are very useful in databases, but HTTP variables have no way of representing `null` as a value, often leading to an empty string and null overlapping. This method will check the value to operate on and return null if it is empty.
toDecimalChar()  : string
Convert a number with a period (dot) as the decimal character to use a different character (typically a comma). Use with a get formatter.

Constants

DATE_EPOCH

Date format: 1331251200. jQuery UI equivalent format: @

public mixed DATE_EPOCH = 'U'

DATE_ISO_1036

Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y

public mixed DATE_ISO_1036 = 'D, j M y'

DATE_ISO_1123

Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy

public mixed DATE_ISO_1123 = 'D, j M Y'

DATE_ISO_2822

Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy

public mixed DATE_ISO_2822 = 'D, j M Y'

DATE_ISO_822

Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y

public mixed DATE_ISO_822 = 'D, j M y'

DATE_ISO_850

Date format: Friday, 09-Mar-12. jQuery UI equivalent format: DD, dd-M-y

public mixed DATE_ISO_850 = 'l, d-M-y'

DATE_ISO_8601

Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd

public mixed DATE_ISO_8601 = 'Y-m-d'

DATE_TIMESTAMP

Date format: 1331251200. jQuery UI equivalent format: @

public mixed DATE_TIMESTAMP = 'U'

DATE_USA

Date format: March-. jQuery UI equivalent format: D, d M yy

public mixed DATE_USA = 'm-d-Y'

Methods

dateFormatToSql()

Convert from a format given by the options parameter to a format that SQL servers will recognise as a date.

public static dateFormatToSql(mixed $format) : string

Typical use of this method is to use it with the Field::getFormatter() and Field::setFormatter() methods of Field where the parameters required for this method will be automatically satisfied.

Parameters
$format : mixed
Tags
callback-param

string $val Value to convert to SQL date format

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Format to convert from using PHP date() options.

Return values
string —

Formatted date or null on error.

dateSqlToFormat()

Convert from SQL date / date time format to a format given by the options parameter.

public static dateSqlToFormat(mixed $format) : string

Typical use of this method is to use it with the Field::getFormatter() and Field::setFormatter() methods of Field where the parameters required for this method will be automatically satisfied.

Parameters
$format : mixed
Tags
callback-param

string $val Value to convert from MySQL date format

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Format to convert to using PHP date() options.

Return values
string —

Formatted date or empty string on error.

datetime()

Convert from one date time format to another.

public static datetime(mixed $from, mixed $to) : string

Typical use of this method is to use it with the Field::getFormatter() and Field::setFormatter() methods of Field where the parameters required for this method will be automatically satisfied.

Parameters
$from : mixed
$to : mixed
Tags
callback-param

string $val Value to convert

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Array with from and to properties which are the formats to convert from and to

Return values
string —

Formatted date or null on error.

explode()

Convert a string of values into an array for use with checkboxes.

public static explode([mixed $char = '|' ]) : string
Parameters
$char : mixed = '|'
Tags
callback-param

string $val Value to convert to from a string to an array

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Field delimiter

Return values
string —

Formatted value or null on error.

fromDecimalChar()

Convert a number from using any character other than a period (dot) to one which does use a period. This is useful for allowing numeric user input in regions where a comma is used as the decimal character. Use with a set formatter.

public static fromDecimalChar([mixed $char = ',' ]) : string
Parameters
$char : mixed = ','
Tags
callback-param

string $val Value to convert to from a string to an array

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Decimal place character (default ',')

Return values
string —

Formatted value or null on error.

ifEmpty()

Formatter that can be used to specify what value should be used if an empty value is submitted by the client-side (e.g. null, 0, 'Not set', etc).

public static ifEmpty(mixed $ret) : string
Parameters
$ret : mixed
Tags
callback-param

string $val Value to convert to from a string to an array

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Empty value

Return values
string —

Formatted value or null on error.

implode()

Convert an array of values from a checkbox into a string which can be used to store in a text field in a database.

public static implode([mixed $char = '|' ]) : string
Parameters
$char : mixed = '|'
Tags
callback-param

string $val Value to convert to from an array to a string

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Field delimiter

Return values
string —

Formatted value or null on error.

nullEmpty()

Convert an empty string to `null`. Null values are very useful in databases, but HTTP variables have no way of representing `null` as a value, often leading to an empty string and null overlapping. This method will check the value to operate on and return null if it is empty.

public static nullEmpty() : string
Tags
callback-param

string $val Value to convert to from a string to an array

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Field delimiter

Return values
string —

Formatted value or null on error.

toDecimalChar()

Convert a number with a period (dot) as the decimal character to use a different character (typically a comma). Use with a get formatter.

public static toDecimalChar([mixed $char = ',' ]) : string
Parameters
$char : mixed = ','
Tags
callback-param

string $val Value to convert to from a string to an array

callback-param

string[] $data Data for the whole row / submitted data

callback-param

string $opts Decimal place character (default ',')

Return values
string —

Formatted value or null on error.


        
On this page

Search results