Fixed an issue in showing insurance balance in payment pop-up.
[openemr.git] / library / date_functions.php
blobd3cf6906caab556b3c6356bb7a863ca45c7adc14
1 <?php
2 // ============================================================
3 // dateformat
4 //
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
12 //
13 // 10.07.2007 - dateformat accepts now an argument
14 // ============================================================
17 function dateformat ($strtime = '', $with_dow = false) {
19 // without an argument, display current date
20 if ( !$strtime ) {
21 $strtime = strtotime('now');
24 // string date is formed by
25 // $dow + date(day) + $nom + date(year) or similar
27 // name the day of the week for different languages
28 $day = date ("w", $strtime); // 0 sunday -> 6 saturday
30 switch ($day) {
31 case 0: $dow = xl ('Sunday'); break;
32 case 1: $dow = xl ('Monday'); break;
33 case 2: $dow = xl ('Tuesday'); break;
34 case 3: $dow = xl ('Wednesday'); break;
35 case 4: $dow = xl ('Thursday'); break;
36 case 5: $dow = xl ('Friday'); break;
37 case 6: $dow = xl ('Saturday'); break;
40 // name of the month in different languages
41 $month = (int) date('m', $strtime);
43 switch ($month) {
44 case 1: $nom = xl ('January'); break;
45 case 2: $nom = xl ('February'); break;
46 case 3: $nom = xl ('March'); break;
47 case 4: $nom = xl ('April'); break;
48 case 5: $nom = xl ('May'); break;
49 case 6: $nom = xl ('June'); break;
50 case 7: $nom = xl ('July'); break;
51 case 8: $nom = xl ('August'); break;
52 case 9: $nom = xl ('September'); break;
53 case 10: $nom = xl ('October'); break;
54 case 11: $nom = xl ('November'); break;
55 case 12: $nom = xl ('December'); break;
58 // Date string format
59 // First, get current language title
60 $languageTitle = getLanguageTitle($_SESSION['language_choice']);
61 switch ($languageTitle) {
62 // standard english first
63 case getLanguageTitle(1):
64 $dt = date ("F j, Y", $strtime);
65 if ($with_dow) $dt = "$dow, $dt";
66 break;
67 case "Swedish":
68 $dt = date ("Y", $strtime) . " $nom " . date("d", $strtime);
69 if ($with_dow) $dt = "$dow $dt";
70 break;
71 case "Spanish":
72 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
73 if ($with_dow) $dt = "$dow $dt";
74 break;
75 case "German":
76 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
77 if ($with_dow) $dt = "$dow $dt";
78 break;
79 case "Dutch":
80 $dt = date ("d", $strtime) . " $nom " . date("Y", $strtime);
81 if ($with_dow) $dt = "$dow $dt";
82 break;
83 // hebrew (israel) , display english NOT jewish calendar
84 case "Hebrew":
85 $dt = date ("F jS Y", $strtime);
86 if ($with_dow) $dt = "$dow, $dt";
87 break;
88 // default case
89 default:
90 $dt = "$nom " . date ("d", $strtime) . ", " . date("Y", $strtime);
91 if ($with_dow) $dt = "$dow, $dt";
94 return $dt;