Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Date

Class Date

Provides methods useful in formatting dates and date timestamps.

Package: minPHP\helpers\date
Located at helpers/date/date.php

Methods summary

public
# __construct( array $formats = null, mixed $timezone_from = null, mixed $timezone_to = null )

Constructs a new Date component using the given date formats in $formats.

Constructs a new Date component using the given date formats in $formats.

Parameters

$formats
array
$formats An array of key/value pairs of PHP date format strings with the following keys: -date A date -day A date with day reference -month A month and year date -year A year date only -date_time A date time
$timezone_from
$timezone_to

See

Date::cast()
public
# setTimezone( string $from = null, string $to = null )

Set the current time zone to be used during date calculations

Set the current time zone to be used during date calculations

Parameters

$from
string
$from The timezone to convert from
$to
string
$to The timezone to convert to
public
# setFormats( array $formats = null )

Sets the formats to use as the pre-defined types.

Sets the formats to use as the pre-defined types.

Parameters

$formats
array
$formats An array of key/value pairs of PHP date format strings with the following keys: -date A date -day A date with day reference -month A month and year date -year A year date only -date_time A date time
public string
# cast( string $date, string $format = "date" )

Format a date using one of the date formats provided to the constructor, or predefined in this class.

Format a date using one of the date formats provided to the constructor, or predefined in this class.

Parameters

$date
string
$date The date string to cast into another format, also handles Unix time stamps
$format
string
$format A predefined date format in Date::$formats, a Date constant, or a date string.

Returns

string
The date formatted using the given format rule, null on error
public string
# dateRange( string $start, string $end, array $formats = null )

Format two dates to represent a range between them.

Format two dates to represent a range between them.

Parameters

$start
string
$start The start date
$end
string
$end The end date
$formats
array
$formats An array of 'start' and 'end' indexes, supplying options for 'same_day', 'same_month', 'same_year', and 'other' formats. Select indexes can be supplied to overwrite only specific rules.

Returns

string
The date range, null on error
public string
# format( string $format, string $date = null )

Format a date using the supply date string

Format a date using the supply date string

Parameters

$format
string
$format The format to use
$date
string
$date The date to format

Returns

string
The formatted date
public integer
# toTime( string $date )

Convert a date string to Unix time

Convert a date string to Unix time

Parameters

$date
string
A date string

Returns

integer
The Unix timestamp of the given date
public array
# getMonths( integer $start = 1, integer $end = 12, string $key_format = "m", string $value_format = "F" )

Returns an array of months in key/value pairs

Returns an array of months in key/value pairs

Parameters

$start
integer
$start The start month (1 = Jan, 12 = Dec)
$end
integer
$end The end month
$key_format
string
$key_format The format for the key
$value_format
string
$value_format The format for the value

Returns

array
An array of key/value pairs representing the range of months
public array
# getYears( integer $start, integer $end, string $key_format = "y", string $value_format = "Y" )

Returns an array of keys in key/value pairs

Returns an array of keys in key/value pairs

Parameters

$start
integer
$start The 4-digit start year
$end
integer
$end The 4-digit end year
$key_format
string
$key_format The format for the key
$value_format
string
$value_format The format for the value

Returns

array
An array of key/value pairs representing the range of years
private
# setDefaultTimezone( string $timezone )

Sets the default timezone

Sets the default timezone

Parameters

$timezone
string
$timezone The default timezone to set for this instance
public array
# getTimezones( string $country = null )

Retrieve all timezones or those for a specific country

Retrieve all timezones or those for a specific country

Parameters

$country
string
$country The ISO 3166-1 2-character country code to fetch timezone information for (PHP 5.3 or greater)

Returns

array
An array of all timezones (or those for the given country) indexed by primary locale, then numerically indexed for each timezone in that locale
private An
# timezoneFromIdentifier( arary & $zone_info, string $identifier )

Constructs the timezone meta data using the given timezone and its identifier

Constructs the timezone meta data using the given timezone and its identifier

Parameters

$zone_info
arary
$zone_info An array of timezone information for the given identifier
$identifier
string
$identifier The timezone identifier

Returns

An
array of timezone meta data including: -id The timezone identifier -name The locale name -offset The offset from UTC in seconds -utc A string containg the HH::MM UTC offset -zone An array of zone names
private static
# insertionSort( array & $array, string $key )

Insertion sort algorithm for numerically indexed arrays with string indexed elements. Will sort items in $array based on values in the $key index. Sorts arrays in place.

Insertion sort algorithm for numerically indexed arrays with string indexed elements. Will sort items in $array based on values in the $key index. Sorts arrays in place.

Parameters

$array
array
$array The array to sort
$key
string
$key The index to sort on
private static
# insertSortInsert( array & $array, integer $length, array $element, string $key )

Insertion sort in inserter. Performs comparison and insertion for the given element within the given array.

Insertion sort in inserter. Performs comparison and insertion for the given element within the given array.

Parameters

$array
array
$array The array to sort
$length
integer
$length The length to sort through
$element
array
$element The element of $array to insert somewhere in $array
$key
string
$key The index to compare
private array
# mergeArrays( array $arr1, array $arr2 )

Extends one array using another to overwrite existing values. Recursively merges data.

Extends one array using another to overwrite existing values. Recursively merges data.

Parameters

$arr1
array
$arr1 The array (default) to be merged into
$arr2
array
$arr2 The array to merge into $arr1

Returns

array
The merged arrays

Magic methods summary

Constants summary

string ATOM "Y-m-d\TH:i:sP"
#
string COOKIE "l, d-M-y H:i:s T"
#
string ISO8601 "Y-m-d\TH:i:sO"
#
string RFC822 "D, d M y H:i:s O"
#
string RFC850 "l, d-M-y H:i:s T"
#
string RFC1036 "D, d M y H:i:s O"
#
string RFC1123 "D, d M Y H:i:s O"
#
string RFC2822 "D, d M Y H:i:s O"
#
string RFC3339 "Y-m-d\TH:i:sP"
#
string RSS "D, d M Y H:i:s O"
#
string W3C "Y-m-d\TH:i:sP"
#

Properties summary

private array $formats
#

Common date formats, predefined for PHP's date function, overwritable by the constructor

Common date formats, predefined for PHP's date function, overwritable by the constructor

private mixed $timezone_from
#
private mixed $timezone_to
#
Blesta API documentation generated by ApiGen 2.8.0