Menu

## Date
in package

Date.php : 18

Class for managing dates and times.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

$lang : mixed
__construct() : mixed
  Class constructor.
age() : string
  คืนค่าอายุเป็นข้อความ ปี เดือน วัน
compare() : array<string|int, mixed>
  Calculates the difference between two dates (e.g., age).
dateName() : string
  Converts a number to the name of the day in the current language.
format() : string
  Converts a time to a date in the specified format.
monthName() : string
  Converts a number to the name of the month in the current language.
parse() : array<string|int, mixed>|bool
  Parses a date string into an array.
timeAgo() : string
  Converts a date to a human-readable time ago format
timeDiff() : int
  Returns the time difference in milliseconds.

### Properties

#### $lang

Date.php : 23
`private static mixed $lang`

### Methods

#### __construct()

Date.php : 28

Class constructor.

`public __construct() : mixed`

##### Return values

mixed —

#### age()

Date.php : 75

คืนค่าอายุเป็นข้อความ ปี เดือน วัน

`public static age(string $date) : string`

##### Parameters

$date : string

##### Return values

string —

#### compare()

Date.php : 51

Calculates the difference between two dates (e.g., age).

`public static compare(string|int $begin_date, istring|int $end_date) : array<string|int, mixed>`

Returns the number of days (can be negative), years, months, and days [days, year, month, day].

##### Parameters

$begin_date : string|int

  The start date or birth date (Unix timestamp or date in the format YYYY-m-d)

$end_date : istring|int

  The end date or today's date (Unix timestamp or date in the format YYYY-m-d)

##### Tags

assert

  (mktime(0, 0, 0, 2, 1, 2016), mktime(0, 0, 0, 3, 1, 2016)) [==] array('days' => 29, 'year' => 0,'month' => 0, 'day' => 29)

assert

  ('2016-3-1', '2016-2-1') [==] array('days' => -29, 'year' => 0,'month' => 0, 'day' => 29)

##### Return values

array<string|int, mixed> —

#### dateName()

Date.php : 124

Converts a number to the name of the day in the current language.

`public static dateName(int $date[, bool $short_date = true ]) : string`

Returns the name of the day (e.g., Sunday...Saturday).

##### Parameters

$date : int

  0-6

$short_date : bool = true

  true (default) for short day name format (e.g., อ.), false for full month name format (e.g., อาทิตย์)

##### Tags

assert

  (0) [==] 'อา.'

assert

  (0, false) [==] 'อาทิตย์'

##### Return values

string —

#### format()

Date.php : 147

Converts a time to a date in the specified format.

`public static format(int|string $time[, string $format = null ]) : string`

Returns the date and time in the specified format.

##### Parameters

$time : int|string

  int for Unix timestamp, string for Y-m-d or Y-m-d H:i:s format (if not specified or empty, it means today)

$format : string = null

  The desired format of the date (if not specified, it uses the format from the language file DATE_FORMAT)

##### Tags

assert

  (0, 'y-m-d H:i:s') [==] date('y-m-d H:i:s')

assert

  (null) [==] ''

assert

  (1454259600, 'Y-m-d H:i:s') [==] '2559-02-01 00:00:00'

##### Return values

string —

#### monthName()

Date.php : 216

Converts a number to the name of the month in the current language.

`public static monthName(int $month[, bool $short_month = true ]) : string`

Returns the name of the month (e.g., January...December).

##### Parameters

$month : int

  1-12

$short_month : bool = true

  true (default) for short month name format (e.g., มค.), false for full month name format (e.g., มกราคม)

##### Tags

assert

  (1) [==] 'ม.ค.'

assert

  (1, false) [==] 'มกราคม'

##### Return values

string —

#### parse()

Date.php : 234

Parses a date string into an array.

`public static parse(string $date) : array<string|int, mixed>|bool`

Returns an array containing year, month, day, hour, minute, second, or an empty array if it's not a date.

##### Parameters

$date : string

  The date string to parse

##### Return values

array<string|int, mixed>|bool —

#### timeAgo()

Date.php : 253

Converts a date to a human-readable time ago format

`public static timeAgo(string $date) : string`

##### Parameters

$date : string

##### Return values

string —

#### timeDiff()

Date.php : 104

Returns the time difference in milliseconds.

`public static timeDiff( $firstTime, $lastTime) : int`

##### Parameters

$firstTime :
$lastTime :

##### Tags

assert

  ('08:00', '09:00') [==] 3600

##### Return values

int —

## Search results