Source Rally PHP Community Scripts .. Sign up .. Login
function for Danish dates
Access: Public      Tags: danish, php, date
Add to favourites       Subscribe comments       Copy code       Bookmark
<?php

#Copyright Regin Gaarsmand 
#http://www.sourcerally.net/regin
#LGPL LICENSE

//Skal være erklæret globalt før ldate() kaldes!
$language = array();
$language['weekdays_long'] = array("søndag",
                                                    
"mandag",
                                                    
"tirsdag",
                                                    
"onsdag",
                                                    
"torsdag",
                                                    
"fredag",
                                                    
"lørdag");
$language['weekdays_short'] = array("søn","man","tir","ons","tor","fre","lør");
$language['months_short'] = array("Jan""Feb""Mar""Apr""Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec");
$language['months_long'] = array("Januar",
                                                  
"Februar",
                                                  
"Marts",
                                                  
"April",
                                                  
"Maj",
                                                  
"Juni",
                                                  
"Juli",
                                                  
"August",
                                                  
"September",
                                                  
"Oktober",
                                                  
"November",
                                                  
"December");

/*
//Eksempel:
$format = "l \\t\h\e F D l M \F \D \l \M \n jS";
$time = time();
echo ldate($format, $time);
*/


function ldate($format$time=time())
{
    global 
$language;
    
preg_match_all('/(F|D|l|M)/',$format$matches);
    
$split preg_split('/(F|D|l|M)/'$format);
    
$l $language['weekdays_long'][date("w",$time)];
    
$F $language['months_long'][(date("n",$time)-1)];
    
$D $language['weekdays_short'][date("w",$time)];
    
$M $language['months_short'][(date("n",$time)-1)];
    
    foreach(
$split as $v)
    {
        
$s each($matches[1]);
        
$date .= date($v,$time);
        if( 
$v[ (strlen($v)-1) ] != "\\" )
        {
            switch(
$s['value'])
            {
                case 
"l":
                
$date .= $l;
                break;
                case 
"F":
                
$date .= $F;
                break;
                case 
"D":
                
$date .= $D;
                break;
                case 
"M":
                
$date .= $M;
                break;
            }
        }
        else
        {
            
$date .= $s['value'];
        }
    }
    return 
$date;
}
?>
Add to favourites       Subscribe comments       Copy code       Bookmark
Sign up to add your own comment here!

Shared by:

regin

Mail user Add to friends
All user contributed content is available under the unless specified otherwise.
Remaining copyrights Regin Gaarsmand © 2006-2008
About www.SourceRally.net