The Date class converts dates and times from one format to another. The current formats are as follows:
Type | Example |
---|---|
unix | 1364858400 |
us | 4/1/2013 |
us_padded | 04/01/2013 |
mmyy | 4/13 |
mmyyyy | 4/2013 |
std | 4/1/2013 4:20pm |
mysql | 2013-04-01 16:20:00 |
time | 4:20pm |
mil_time | 16:20 |
Date class usage is really simple. A date of any convertible type is supplied to the method which type is desired.
// The date supplied is a unix timestamp $supplied_date = 1364858400; // We want to convert it to std $converted_date = \Date::std( $supplied_date ); // 4/1/2013 4:20pm echo $converted_date
When converting a mmyy or mmyyyy date to a format that has a day value, we may need to supply the value for the desired day.
// The date has no day value $supplied_date = '4/13'; // Set the day value \Date::day(30); // We want to convert it to std $converted_date = \Date::std( $supplied_date ); // 4/30/2013 12:00am echo $converted_date