Date_Time_Converter

Date and Time Converter by Elac v0.9.3 elacdude@gmail.com www.elacdude.com

You are free to use this code free of charge, modify it, and distrubute it, just leave this comment block at the top of this file.

 Changes/Modifications
 6/24/08 - Version 0.9.2 released.  Minor additions
             - Added "S" support. (th, rd, st, nd.  example: 5th)
             - Added a few more abbreviations for units of time in calculate()  (s.  sec. secs. min. mins. m.  and more)
             - Added example.php (php examples and usage) and date_time_formats.html (list of supported date/time formats) to the package.
 6/25/08 - Version 0.9.3 released.  Bug fixes
             - Fixed month subtraction (wrap to previous year) bug
             - Fixed month and year "$only_return_the_value=true" bug.  If you calculated by months or years, and set
               $only_return_the_value=true, it would overwrite the values instead of just returning them.
             - Fixed the "D" (Sun, Mon, Tue) bug.  If you supplied "D" and "d" in the same mask, it would not return the correct output.
             - Changed the names of public variables "day", "month", and "year" added "s" at the end for consistency purposes
 11/14/08 - Version 0.9.4 released.  Bug fix
             - Got rid of the _one_dig_num function and used ltrim($num "0") instead
package

Default

Methods

Constructor. This is where you supply the date. Accepts almost any format of date as long as you supply the correct mask. DOES accept dates without leading zeros (n,j,g,G) as long as they aren't bunched together.

__construct( $sDate, $sFormat)

ie: ("1152008", "njY") wont work; ("1/15/2008", "n/j/2008") will work. Example: $obj = new Date_Time_Calc('12/30/2008 17:40:00', 'm/d/Y H:i:s');

Arguments

$sDate

$sFormat

__destruct

__destruct()

Private Function. Converts a date into a timestamp. Accepts almost any format of date as long as you supply the correct mask. DOES accept dates without leading zeros (n,j,g,G) as long as they aren't bunched together.

_date_to_timestamp( $thedate, $mask)

ie: ("1152008", "njY") wont work; ("1/15/2008", "n/j/2008") will work

Arguments

$thedate

$mask

Private function. Resets date and time unit variables to default

_default_date_time_units()

Private Function. Converts a textual month into a digit. Accepts almost any textual format of a month including abbreviations.

_month_num( $themonth, $return_two_digit = false)

Example: _month_num("jan"); //returns '1' Example2: _month_num("january", true); //returns '01'

Arguments

$themonth

$return_two_digit

Sets a new format/mask for the date using the php date() style formatting Example: $obj->convert("M j Y H:i:s A");

convert( $new_mask, $save = true)

Arguments

$new_mask

$save

Changes the date to a new one.

set_date_time( $start_date_time, $mask)

Example: $obj->set_date_time('11/20/2005 07:40:00 AM', 'm/d/Y H:i:s A');

Arguments

$start_date_time

$mask

Properties

The date to be calculated in timestamp format

date_time_stamp :mixed
var

Type(s)

mixed

The date to be calculated. ex: 12/30/2008 17:40:00

date_time :string
var

Type(s)

string

The php date() style format that $date_time is in. ex: m/d/Y H:i:s

date_time_mask :string
var

Type(s)

string

seconds

seconds :

Type(s)

minutes

minutes :

Type(s)

hours

hours :

Type(s)

days

days :

Type(s)

months

months :

Type(s)

years

years :

Type(s)

ampm

ampm :

Type(s)