Zikula: A Flexible Open Source Content Management System
home | forum | international support | contact us

Docs For Class DateUtil

Class: DateUtil

Source Location: /pnobjlib/DateUtil.class.php

Class Overview


DateUtil

Methods


Inherited Variables

Inherited Methods


Class Details

[line 25] DateUtil



[ Top ]

Class Methods


method buildDatetime [line 126]

datetime buildDatetime( year $year, month $month, day $day, hour $hour, minute $minute, second $second, [format $format = DATEFORMAT_FIXED])

Build a datetime string from the supplied fields



Tags:

return:  The datetime formatted according to the specified format


Parameters:

year   $year   The year
month   $month   The month
day   $day   The day
hour   $hour   The hour (optional) (default==0)
minute   $minute   The minute (optional) (default==0)
second   $second   The second (optional) (default==0)
format   $format   The format to use when formatting the date (optional)

[ Top ]

method formatDatetime [line 98]

datetime formatDatetime( [datetime $datetime = null], [format $format = DATEFORMAT_FIXED])

Reformat a given datetime according to the specified format



Tags:

return:  The datetime formatted according to the specified format


Parameters:

datetime   $datetime   The (string) datetime to reformat
format   $format   The format to use when formatting the date (optional)

[ Top ]

method getDateofKW [line 423]

unixtimestamp getDateofKW( day $day, kw $kw, year $year, [flag $flag = 's'])

Calculate day-x of KW in a YEAR



Tags:

return:  or sqlDate


Parameters:

day   $day   0 for monday, 6 for sunday,....
kw   $kw   week of the year
year   $year   year
flag   $flag   u or s (unixtimestamp or MySQLDate)

[ Top ]

method getDatetime [line 35]

datetime getDatetime( [time $time = ''], [format $format = DATEFORMAT_FIXED])

Return a formatted datetime for the given timestamp (or for now)



Tags:

return:  The datetime formatted according to the specified format


Parameters:

time   $time   The timestamp (string) which we wish to format (default==now)
format   $format   The format to use when formatting the date (optional)

[ Top ]

method getDatetimeDiff [line 347]

array getDatetimeDiff( date1 $date1, date2 $date2)

Return an structured array holding the differences between 2 dates.

The returned array will be structured as follows:
Array (
[d] => _numeric_day_value_
[h] => _numeric_hour_value_
[m] => _numeric_minute_value_
[s] => _numeric_second_value_ )




Tags:

return:  The structured array containing the datetime difference


Parameters:

date1   $date1   The first date
date2   $date2   The second date

[ Top ]

method getDatetimeDiff_AsField [line 381]

float getDatetimeDiff_AsField( date1 $date1, date2 $date2, field $field)

Return an field holding the differences between 2 dates expressed in units of the field requested

Since the date fields can change depending on the date format, the following convention is used when referring to date fields:
Field 1 -> Year
Field 2 -> Month
Field 3 -> Day
Field 4 -> Hour
Field 5 -> Minute
Field 6 -> Second




Tags:

return:  The difference in units of the specified field


Parameters:

date1   $date1   The first date
date2   $date2   The second date
field   $field   The field (unit) in which we want the different

[ Top ]

method getDatetime_Date [line 243]

string getDatetime_Date( [datetime $datetime = ''], [format $format = DATEFORMAT_FIXED])

Return the date portion of a datetime timestamp



Tags:

return:  The Date portion of the specified datetime


Parameters:

datetime   $datetime   The date to parse (optional) (default=='', reverts to now)
format   $format   The format to use when formatting the date (optional)

[ Top ]

method getDatetime_Field [line 305]

string getDatetime_Field( datetime $datetime, field $field)

Return the requested field from the supplied date

Since the date fields can change depending on the date format, the following convention is used when referring to date fields:
Field 1 -> Year
Field 2 -> Month
Field 3 -> Day
Field 4 -> Hour
Field 5 -> Minute
Field 6 -> Second




Tags:

return:  The requested datetime field


Parameters:

datetime   $datetime   The field number to return
field   $field   The date to parse (default=='', reverts to now)

[ Top ]

method getDatetime_NextDay [line 144]

datetime getDatetime_NextDay( [days $num = 1], [format $format = DATEFORMAT_FIXED], [hour $year = null], [minute $month = null], [second $day = null], [ $hour = null], [ $minute = null], [ $second = null])

Return a formatted datetime at the end of the business day n days from now



Tags:

return:  The datetime formatted according to the specified format


Parameters:

days   $num   The number of days to advance (optional) (detault==1)
format   $format   The format to use when formatting the date (optional)
hour   $year   The hour of the target time to set (optional) (default=null, means params is taken from now)
minute   $month   The minute of the target time to set (optional) (default=null, means params is taken from now)
second   $day   The second of the target time to set (optional) (default=null, means params is taken from now)
   $hour  
   $minute  
   $second  

[ Top ]

method getDatetime_NextMonth [line 197]

datetime getDatetime_NextMonth( [num $num = 1], [format $format = DATEFORMAT_FIXED], [year $year = null], [month $month = null], [day $day = null], [hour $hour = null], [minute $minute = null], [second $second = null])

Return a formatted datetime at the end of the business day n months from now



Tags:

return:  The datetime formatted according to the specified format


Parameters:

num   $num   The number of months to advance (optional) (default=1)
format   $format   The format to use when formatting the date (optional)
year   $year   The year of the target time to set (optional) (default=null, means param is taken from now)
month   $month   The month of the target time to set (optional) (default=null, means param is taken from now)
day   $day   The day of the target time to set (optional) (default=null, means param is taken from now)
hour   $hour   The hour of the target time to set (optional) (default=null, means params is taken from now)
minute   $minute   The minute of the target time to set (optional) (default=null, means params is taken from now)
second   $second   The second of the target time to set (optional) (default=null, means params is taken from now)

[ Top ]

method getDatetime_NextWeek [line 170]

datetime getDatetime_NextWeek( [num $num = 1], [format $format = DATEFORMAT_FIXED], [year $year = null], [month $month = null], [day $day = null], [hour $hour = null], [minute $minute = null], [second $second = null])

Return a formatted datetime at the end of the business day n week from now



Tags:

return:  The datetime formatted according to the specified format


Parameters:

num   $num   The number of weeks to advance (optional) (detault==1)
format   $format   The format to use when formatting the date (optional)
year   $year   The year of the target time to set (optional) (default=null, means param is taken from now)
month   $month   The month of the target time to set (optional) (default=null, means param is taken from now)
day   $day   The day of the target time to set (optional) (default=null, means param is taken from now)
hour   $hour   The hour of the target time to set (optional) (default=null, means param is taken from now)
minute   $minute   The minute of the target time to set (optional) (default=null, means param is taken from now)
second   $second   The second of the target time to set (optional) (default=null, means param is taken from now)

[ Top ]

method getDatetime_NextYear [line 223]

datetime getDatetime_NextYear( [num $num = 1], [format $format = DATEFORMAT_FIXED], [year $year = null], [month $month = null], [day $day = null], [hour $hour = null], [minute $minute = null], [second $second = null])

Return a formatted datetime at the end of the business day n years from now



Tags:

return:  The datetime formatted according to the specified format


Parameters:

num   $num   The number of years to advance (optional) (default=1)
format   $format   The format to use when formatting the date (optional)
year   $year   The year of the target time to set (optional) (default=null, means param is taken from now)
month   $month   The month of the target time to set (optional) (default=null, means param is taken from now)
day   $day   The day of the target time to set (optional) (default=null, means param is taken from now)
hour   $hour   The hour of the target time to set (optional) (default=null, means params is taken from now)
minute   $minute   The minute of the target time to set (optional) (default=null, means params is taken from now)
second   $second   The second of the target time to set (optional) (default=null, means params is taken from now)

[ Top ]

method getDatetime_Time [line 269]

string getDatetime_Time( [datetime $datetime = ''], [format $format = DATEFORMAT_FIXED])

Return the time portion of a datetime timestamp



Tags:

return:  The Time portion of the specified datetime


Parameters:

datetime   $datetime   The date to parse (optional) (default=='', reverts to now)
format   $format   The format to use when formatting the date (optional)

[ Top ]

method getDaysInMonth [line 457]

integer getDaysInMonth( month $month, year $year)

Return a the number of days in the given month/year



Tags:

return:  The number of days in the given month/year


Parameters:

month   $month   The (human) month number to check
year   $year   The year number to check

[ Top ]

method getMonthDates [line 515]

integer getMonthDates( month $month, year $year)

Return an array of dates for the given month



Tags:

return:  The number of days in the given month/year


Parameters:

month   $month   The (human) month number to check
year   $year   The year number to check

[ Top ]

method getWeekdaysInMonth [line 492]

integer getWeekdaysInMonth( month $month, year $year)

Return an array of weekdays for the given month



Tags:

return:  The number of days in the given month/year


Parameters:

month   $month   The (human) month number to check
year   $year   The year number to check

[ Top ]

method makeTimestamp [line 619]

int makeTimestamp( [int $string = ''])

create a unix timestamp from either a unix timestamp (sic!), a MySQL timestamp or a string. This code is taken from smarty_make_timestamp.php, credits go to Monte Ohrt <monte at ohrt dot com>

We use a copy of the code here due to performance reasons.




Tags:

return:  a unix timestamp


Parameters:

int   $string   or text a timestamp in one of the formats mentioned

[ Top ]

method parseUIDate [line 538]

date parseUIDate( text $text)

Parses a user interface date string (excluding time) into a timestamp

Currently only the format YYYY-MM-DD is supported, but future versions will be able to parse more diverse formats.




Tags:

return:  The timestamp or null in case of errors


Parameters:

text   $text   The UI date string

[ Top ]

method parseUIDateTime [line 569]

date parseUIDateTime( text $text)

Parses a user interface date+time string into a timestamp

Currently only the format YYYY-MM-DD HH:MM is supported, but future versions will be able to parse more diverse formats.




Tags:

return:  The timestamp or null in case of errors


Parameters:

text   $text   The UI date+time string

[ Top ]

Packages:

Files:

Classes: