Merge pull request #956 to fix therapy groups permissions
[openemr.git] / library / formatting_DateToYYYYMMDD_js.js.php
blob9664628c6c7b297c716d56f9f7886cdd0c9dd615
1 <?php
2 /**
3 * this is the javascript DateToYYYYMMDD_js to allow date internationalization
4 * converts date back to YYYY-MM-DD format
6 * Copyright (C) 2016 Shachar Zilbershlag <shaharzi@matrix.co.il>
7 * Copyright (C) 2016 Amiel Elboim <amielel@matrix.co.il>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @package OpenEMR
21 * @author Shachar Zilbershlag <shaharzi@matrix.co.il>
22 * @author Amiel Elboim <amielel@matrix.co.il>
23 * @link http://www.open-emr.org
26 function DateToYYYYMMDD_js(value){
27 var value = value.replace(/\//g,'-');
28 var parts = value.split('-');
29 var date_display_format = <?php echo (empty($GLOBALS['date_display_format']) ? 0 : $GLOBALS['date_display_format']) ?>;
31 if (date_display_format == 1) // mm/dd/yyyy, note year is added below
32 value = parts[2] + '-' + parts[0] + '-' + parts[1];
33 else if (date_display_format == 2) // dd/mm/yyyy, note year is added below
34 value = parts[2] + '-' + parts[1] + '-' + parts[0];
36 return value;