Login   Register  
PHP Classes
elePHPant
Icontem

File: ReadMe.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Volker Rubach  >  Date Convert  >  ReadMe.txt  >  Download  
File: ReadMe.txt
Role: Documentation
Content type: text/plain
Description: ReadMe
Class: Date Convert
Convert and validate date values
Author: By
Last change:
Date: 2012-02-10 16:23
Size: 11,520 bytes
 

Contents

Class file image Download
/**************************************************************************
 *
 * Class:         Class 'Date' (class_date.inc.php)
 *
 * Version:       1.1
 *
 * Copyright:     (c) 2010 Volker Rubach - All rights reserved
 *
 * Description:   This class contains functions, to convert dates between
 *                German format and ISO 9075 standard (MySQL format), and
 *                some other functions for the evaluation of a date or to
 *                format a date in different versions.
 *
 *************************************************************************/


 Include class
 -------------
 <code>
    include( '../ <path> /class_date.inc.php' );
 </code>


 Create instance
 ---------------
 <code>
    $date = new Date();
 </code>


 Error handling
 ----------------
 trigger_error( 'FUNCTION <name>: '<message>', E_USER_NOTICE );
 trigger_error( 'FUNCTION <name>: '<message>', E_USER_WARNING );
 trigger_error( 'FUNCTION <name>: '<message>', E_USER_ERROR );


 Overview
 --------
 createTimestamp   Create timestamp (MySQL format)
 tsDateIso         Get ISO date from timestamp
 tsDateGer         Get GER date from Timestamp
 curDateIso        Get current date in ISO format
 curDateGer        Get current date in GER format
 curTimeLong       Get current time (long)
 curTimeShort      Get current time (short)
 daysInMonth       Get days in month
 getWeek           Get current week
 getWeekday        Get current weekday
 getDayName        Get day name (eng or ger / long or short)
 getMonName        Get month name (eng or ger / long or short)
 splitDate         Splitting date in components
 checkDate         Checking date (numbers, correct date)
 dateInCurMonth    Checking if date is in current month
 dateInCurYear     Checking if date is in current year
 compDate          Comparing date with current date
 isWeekday         Checking if particular weekday
 iso2ger           Change Date Format From ISO To GER
 ger2iso           Change Date Format From GER To ISO
 dateWD            Date with weekday (eng or ger / long or short)
 dateMN            Date with month name (eng or ger / long or short)
 dateSWDLM         Date with short weekday and long month name
 calcAge           Calculate age
 prevDay           Calculate the previous day
 nextDay           Calculate the next day
 prevMonth         Calculate the previous month
 nextMonth         Calculate the next month
 addDatePart       Add a predefined value to a part of date
 subDatePart       Subtract a predefined value from a part of date


 createTimestamp -> Create timestamp (MySQL format)
 --------------------------------------------------
 @input    Nothing
 @return   Timestamp (yyyy-mm-dd hh:mm:ss)

 <code>
    $<var name> = $date->createTimestamp();
 </code>


 tsDateIso -> Get ISO date from timestamp
 ----------------------------------------
 @input    Timestamp (yyyy-mm-dd hh:mm:ss)
 @return   ISO Date (yyyy-mm-dd)

 <code>
    $<var name> = $date->tsDateIso($<var name>);
 </code>


 tsDateGer -> Get GER date from timestamp
 ----------------------------------------
 @input    Timestamp (yyyy-mm-dd hh:mm:ss)
 @return   GER Date (dd.mm.yyyy)

 <code>
    $<var name> = $date->tsDateGer($<var name>);
 </code>


 curDateIso -> Get current date in ISO format
 --------------------------------------------
 @input    Nothing
 @return   ISO Date (yyyy-mm-dd)

 <code>
    $<var name> = $date->curDateIso();
 </code>


 curDateGer -> Get current date in GER format
 --------------------------------------------
 @input    Nothing
 @return   GER Date (dd-mm-yyyy)

 <code>
    $<var name> = $date->curDateGer();
 </code>


 curTimeLong -> Get current time (long)
 --------------------------------------
 @input    Nothing
 @return   Long Time (hh:mm:ss)

 <code>
    $<var name> = $date->curTimeLong();
 </code>


 curTimeShort -> Get current time (short)
 ----------------------------------------
 @input    Nothing
 @return   Short Time (hh:mm)

 <code>
    $<var name> = $date->curTimeShort();
 </code>


 daysInMonth -> Get days in month
 --------------------------------
 @input    Nothing
 @return   Days (number)

 <code>
    $<var name> = $date->daysInMonth(>);
 </code>


 getWeek -> Get days in month
 --------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Week (number)

 <code>
    $<var name> = $date->getWeek($<var name>);
 </code>


 getWeekday -> Get weekday
 -------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Weekday (number)

 WkDays:	0 = Sunday
			1 = Monday
			2 = Tuesday
			3 = Wednesday
			4 = Thursday
			5 = Friday
			6 = Saturday

 <code>
    $<var name> = $date->getWeekday($<var name>);
 </code>


 getDayName -> Get day name
 --------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Day name (eng or ger / long or short)

 Lang.:	  'e' = english day name
          'g' = german day name

 Length:  'l' = long day name
          's' = short day name

 <code>
    $<var name> = $date->getDayName($<var name>, <language>, <length>);
 </code>


 getMonName -> Get month name
 ----------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Month name (eng or ger / long or short)

 Lang.:	  'e' = english day name
          'g' = german day name

 Length:  'l' = long day name
          's' = short day name

 <code>
    $<var name> = $date->getMonName($<var name>, <language>, <length>);
 </code>


 splitDate -> Splitting date in components
 -----------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Array with Day (dd), Month (mm) and Year(yyyy)

 <code>
    $dateArr = $date->splitDate($<var name>);
 </code>

 Array:	 $dateArr[0] = Day
         $dateArr[1] = Month
         $dateArr[2] = Year


 checkDate -> Checking date (correct input and correct date)
 -----------------------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   True or False

 <code>
    if ($date->checkDate($<var name>))
       { ... } ;
    else
       { ... } ;
 </code>


 dateInCurMonth -> Checking if date is in current month
 ------------------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   True or False

 <code>
    if ($date->dateInCurMonth($<var name>))
       { ... } ;
    else
       { ... } ;
 </code>


 dateInCurYear -> Checking if date is in current year
 ----------------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   True or False

 <code>
    if ($date->dateInCurYear($<var name>))
       { ... } ;
    else
       { ... } ;
 </code>


 compDate -> Comparing date with current date
 --------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   True or False

 <code>
    if ($date->compDate($<var name>))
       { ... } ;
    else
       { ... } ;
 </code>


 isWeekday -> Checking if particular weekday
 -------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   True or False

 WkDays:	0 = Sunday
			1 = Monday
			2 = Tuesday
			3 = Wednesday
			4 = Thursday
			5 = Friday
			6 = Saturday

 <code>
    if ($date->isWeekday($<var name>, <weekday number>))
       { ... } ;
    else
       { ... } ;
 </code>


 iso2ger -> Change date format from ISO to GER
 ---------------------------------------------
 @input    ISO date (yyyy-mm-dd)
 @return   GER date (dd.mm.yyyy)

 <code>
    $<var name> = $date->iso2ger($<var name>);
 </code>


 ger2iso -> Change date format from GER to ISO
 ---------------------------------------------
 @input    GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd)

 <code>
    $<var name> = $date->ger2iso($<var name>);
 </code>


 dateWD -> Date with weekday
 ---------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Date (DDD dd.mm.yyyy or DDDDD dd.mm.yyyy)

 Lang.:	  'e' = english day name
          'g' = german day name

 Length:  'l' = long day name
          's' = short day name

 <code>
    $<var name> = $date->dateWD($<var name>, <language>, <length>);
 </code>


 dateMN -> Date with month name
 ------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Date (dd. MMM yyyy or dd. MMMMM yyyy)

 Lang.:	  'e' = english day name
          'g' = german day name

 Length:  'l' = long day name
          's' = short day name

 <code>
    $<var name> = $date->dateMN($<var name>, <language>, <length>);
 </code>


 dateSWDLM -> Date with short weekday and long month name
 --------------------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Date (DDD dd. MMMMM yyyy)

 Lang.:	  'e' = english day name
          'g' = german day name

 <code>
    $<var name> = $date->dateSWDLM($<var name>, <language>);
 </code>


 calcAge -> Calculate age
 ------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   Age (number)

 <code>
    $<var name> = $date->calcAge($<var name>);
 </code>


 prevDay -> Calculate the previous day
 -------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)

 <code>
    $<var name> = $date->prevDay($<var name>);
 </code>


 nextDay -> Calculate the next day
 ---------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)

 <code>
    $<var name> = $date->nextDay($<var name>);
 </code>


 prevMonth -> Calculate the previous month
 -----------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)

 <code>
    $<var name> = $date->prevMonth($<var name>);
 </code>


 nextMonth -> Calculate the next month
 -------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)

 <code>
    $<var name> = $date->nextMonth($<var name>);
 </code>


 addDatePart -> Add a predefined value to a part of date
 -------------------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)

 Part:  d = add value at day
        m = add value at month
        y = add value at year

 <code>
    $<var name> = $date->addDatePart($<var name>, <part>, <value>);
 </code>


 subDatePart -> Subtract a predefined value from a part of date
 --------------------------------------------------------------
 @input    ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)
 @return   ISO date (yyyy-mm-dd) / GER date (dd.mm.yyyy)

 Part:  d = add value at day
        m = add value at month
        y = add value at year

 <code>
    $<var name> = $date->subDatePart($<var name>, <part>, <value>);
 </code>