Location: PHPKode > projects > Tin Can Jukebox > tincanjukebox/lib/j_utilFuncs_dates.php
//some date stuff.  These all take and return a date array (from getdate()).
function j_getDateArray($date){//get a date array from string date.
	if($date=="now") return getdate();
	return getdate(strtotime($date));
function j_getDatePartsArray(){//returns the list of acceptable dateparts in an assoc array
    return $dateparts;
function j_firstOfMonth($aDate){//returns the date array of the first day of the month.
    return getdate($start);
function j_lastOfMonth($aDate){//returns the date array of the last day of the month.
    $end=mktime(0,0,0,$aDate['mon']+1,0,$aDate['year']);//the zeroth day of next month is the last day of this month.
    return getdate($end);
function j_startOfDay($aDate){
    return getdate($date);
function j_endOfDay($aDate){
    return getdate($date);
function j_dateAdd($aDate,$datePart,$num){/*datePart (string) can be:
    $num can be +/- integer
    NOTE; if adding months, you should always use first of month due to
    variable size of months.. this won't crash, but adding 1 month to 1/31 will
    return something like 3/3 (depending on leap year).  Same applies to years if
    day is 2/29.  All others should work fine though.
    return getdate($date);
function j_getTimeStamp($aDate){//returns unix time stamp for passed date array.
    return mktime($aDate['hours'],$aDate['minutes'],$aDate['seconds'],$aDate['mon'],$aDate['mday'],$aDate['year']);
function j_getNiceDate($aDate,$showTime=true){//returns a date suitable for display (5/12/2005 2:15 pm)
	//$aDate is a date array like what is returned by getdate();  This assumes the timestamp in datearray is accurate and this uses time info.
        if($showTime &&($aDate['seconds']!=0 || $aDate['minutes']!=0 || $aDate['hours']!=0)){
            $format.=" g:i a";
	return $dateStr;	 
function j_get_YYYYMMDD_date($aDate){
        $format="Y/m/d";//Note; this format is relied on elsewhere.. if need to change, leave this as default.
        return $dateStr;
function j_dateDiff($aDate1,$aDate2,$datePart){//NO WORKIE YET (not handling 32 days...)
    /*returns number of $dateParts difference ($aDate2-$aDate1) between passed dates..
    negative means that $aDate1 is after $aDate2.
    dateparts can be hours,minutes,seconds,mon,day,year,week. */
    return $num;
Return current item: Tin Can Jukebox