| Package | system.utils |
|---|---|
| Inheritance | class CTimestamp |
| Since | 1.0 |
| Version | $Id: CTimestamp.php 1571 2009-12-11 02:39:21Z qiang.xue $ |
| Method | Description | Defined By |
|---|---|---|
| formatDate() | Formats a timestamp to a date string. | CTimestamp |
| get4DigitYear() | Returns 4-digit representation of the year. | CTimestamp |
| getDate() | Returns the getdate() array. | CTimestamp |
| getDayofWeek() | Gets day of week, 0 = Sunday,... 6=Saturday. | CTimestamp |
| getGMTDiff() | CTimestamp | |
| getTimestamp() | Generates a timestamp. | CTimestamp |
| isLeapYear() | Checks for leap year, returns true if it is. No 2-digit year check. Also | CTimestamp |
| isValidDate() | Checks to see if the year, month, day are valid combination. | CTimestamp |
| isValidTime() | Checks to see if the hour, minute and second are valid. | CTimestamp |
| Method | Description | Defined By |
|---|---|---|
| digitCheck() | Fix 2-digit years. Works for any century. | CTimestamp |
|
protected static integer digitCheck(integer $y)
| ||
| $y | integer | year |
| {return} | integer | change two digit year into multiple digits |
Fix 2-digit years. Works for any century. Assumes that if 2-digit is more than 30 years in future, then previous century.
|
public static string formatDate(string $fmt, integer $d=false, boolean $is_gmt=false)
| ||
| $fmt | string | format pattern |
| $d | integer | timestamp |
| $is_gmt | boolean | whether this is a GMT timestamp |
| {return} | string | formatted date based on timestamp $d |
Formats a timestamp to a date string.
|
public static integer get4DigitYear(integer $y)
| ||
| $y | integer | year |
| {return} | integer | 4-digit representation of the year |
Returns 4-digit representation of the year.
|
public static array getDate(integer $d=false, boolean $fast=false, boolean $gmt=false)
| ||
| $d | integer | original date timestamp. False to use the current timestamp. |
| $fast | boolean | false to compute the day of the week, default is true |
| $gmt | boolean | true to calculate the GMT dates |
| {return} | array | an array with date info. |
Returns the getdate() array.
|
public static integer getDayofWeek(integer $year, integer $month, integer $day)
| ||
| $year | integer | year |
| $month | integer | month |
| $day | integer | day |
| {return} | integer | day of week |
Gets day of week, 0 = Sunday,... 6=Saturday. Algorithm from PEAR::Date_Calc
|
public static integer getGMTDiff()
| ||
| {return} | integer | get local time zone offset from GMT |
|
public static integer|float getTimestamp(integer $hr, integer $min, integer $sec, integer $mon=false, integer $day=false, integer $year=false, boolean $is_gmt=false)
| ||
| $hr | integer | hour |
| $min | integer | minute |
| $sec | integer | second |
| $mon | integer | month |
| $day | integer | day |
| $year | integer | year |
| $is_gmt | boolean | whether this is GMT time |
| {return} | integer|float | a timestamp given a local time. Originally by jackbbs. |
Generates a timestamp. Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
|
public static boolean isLeapYear(integer $year)
| ||
| $year | integer | year to check |
| {return} | boolean | true if is leap year |
Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly.
|
public static boolean isValidDate(integer $y, integer $m, integer $d)
| ||
| $y | integer | year |
| $m | integer | month |
| $d | integer | day |
| {return} | boolean | true if valid date, semantic check only. |
Checks to see if the year, month, day are valid combination.
|
public static boolean isValidTime(integer $h, integer $m, integer $s, boolean $hs24=true)
| ||
| $h | integer | hour |
| $m | integer | minute |
| $s | integer | second |
| $hs24 | boolean | whether the hours should be 0 through 23 (default) or 1 through 12. |
| {return} | boolean | true if valid date, semantic check only. |
Checks to see if the hour, minute and second are valid.
Be the first person to leave a comment
Please login to leave your comment.