2 // ============================================================
5 // return a formated string for date
6 // @args: string (date string), boolean (include day of week)
7 // (it uses $_SESSION['language_choice'] )
8 // @return: $date_string (string) - formated string
9 // Cristian Navalici lemonsoftware at gmail dot com
11 // For Hebrew must be implemented a special calendar functions
13 // 10.07.2007 - dateformat accepts now an argument
14 // ============================================================
16 function dateformat ($strtime = '', $with_dow = false) {
18 // without an argument, display current date
20 $strtime = strtotime('now');
23 // string date is formed by
24 // $dow + date(day) + $nom + date(year) or similar
26 // name the day of the week for different languages
27 $day = date ("w", $strtime); // 0 sunday -> 6 saturday
30 case 0: $dow = xl ('Sunday'); break;
31 case 1: $dow = xl ('Monday'); break;
32 case 2: $dow = xl ('Tuesday'); break;
33 case 3: $dow = xl ('Wednesday'); break;
34 case 4: $dow = xl ('Thursday'); break;
35 case 5: $dow = xl ('Friday'); break;
36 case 6: $dow = xl ('Saturday'); break;
39 // name of the month in different languages
40 $month = (int) date('m', $strtime);
43 case 1: $nom = xl ('January'); break;
44 case 2: $nom = xl ('February'); break;
45 case 3: $nom = xl ('March'); break;
46 case 4: $nom = xl ('April'); break;
47 case 5: $nom = xl ('May'); break;
48 case 6: $nom = xl ('June'); break;
49 case 7: $nom = xl ('July'); break;
50 case 8: $nom = xl ('August'); break;
51 case 9: $nom = xl ('September'); break;
52 case 10: $nom = xl ('October'); break;
53 case 11: $nom = xl ('November'); break;
54 case 12: $nom = xl ('December'); break;
58 // First, get current language title
59 $languageTitle = getLanguageTitle($_SESSION['language_choice']);
60 switch ($languageTitle) {
61 // standard english first
62 case getLanguageTitle(1):
63 $dt = date ("F j, Y", $strtime);
64 if ($with_dow) $dt = "$dow, $dt";
67 $dt = date ("Y", $strtime) . " $nom " . date("d", $strtime);
68 if ($with_dow) $dt = "$dow $dt";
71 case "Spanish (Spain)":
72 case "Spanish (Latin American)":
73 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
74 if ($with_dow) $dt = "$dow $dt";
77 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
78 if ($with_dow) $dt = "$dow $dt";
81 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
82 if ($with_dow) $dt = "$dow $dt";
84 // hebrew (israel) , display english NOT jewish calendar
86 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
87 if ($with_dow) $dt = "$dow, $dt";
91 $dt = "$nom " . date ("d", $strtime) . ", " . date("Y", $strtime);
92 if ($with_dow) $dt = "$dow, $dt";