Mega Code Archive

 
Categories / Php / Date Time
 

This class can be used for local date notations

You need to translate the week-days and month names in your local language. <?php class local_date { var $week_day; var $day; var $month; var $year; function local_date() { //constructor $this->week_day = date("l"); $this->day = date("j"); $this->month = date("n"); $this->year = date("Y"); } //translate in local language function get_day() { $nl_day = array("Monday" => "Maandag", "Tuesday" => "Dinsdag", "Wednesday" => "Woensdag", "Thursday" => "Donderdag", "Friday" => "Vrijdag", "Saturday" => "Zaterdag", "Sunday" => "Zondag"); return $nl_day[$this->week_day]; } function get_month() { $nl_month = array("1" => "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "october", "november", "december"); return $nl_month[$this->month]; } function build_date() { $long_date = $this->day." ".$this->get_month()." ".$this->year; return $long_date; } } // example for use $my_date = new local_date; echo $my_date->get_day().", ".$my_date->build_date(); // this will output "Woensdag, 7 juli 2004" ?>