diff --git a/include/class.forms.php b/include/class.forms.php
index 356c504da90a38d2357975e5777a310c5e3d3ee1..4c64b9a538f5eb2255b45ca10137388ea42cead1 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -903,21 +903,24 @@ class CheckboxWidget extends Widget {
 
 class DatetimePickerWidget extends Widget {
     function render() {
+        global $cfg;
+
         $config = $this->field->getConfiguration();
         if ($this->value) {
             $this->value = (is_int($this->value) ? $this->value :
-                    strtotime($this->value));
+                DateTime::createFromFormat($cfg->getDateFormat(), $this->value)
+                ->format('U'));
             if ($config['gmt'])
                 $this->value += 3600 *
                     $_SESSION['TZ_OFFSET']+($_SESSION['TZ_DST']?date('I',$this->value):0);
 
             list($hr, $min) = explode(':', date('H:i', $this->value));
-            $this->value = date('m/d/Y', $this->value);
+            $this->value = date($cfg->getDateFormat(), $this->value);
         }
         ?>
         <input type="text" name="<?php echo $this->name; ?>"
             value="<?php echo Format::htmlchars($this->value); ?>" size="12"
-            autocomplete="off" />
+            autocomplete="off" class="dp" />
         <script type="text/javascript">
             $(function() {
                 $('input[name="<?php echo $this->name; ?>"]').datepicker({
@@ -932,7 +935,8 @@ class DatetimePickerWidget extends Widget {
                     numberOfMonths: 2,
                     showButtonPanel: true,
                     buttonImage: './images/cal.png',
-                    showOn:'both'
+                    showOn:'both',
+                    dateFormat: $.translate_format(<?php echo $cfg->getDateFormat(); ?>),
                 });
             });
         </script>
diff --git a/scp/js/scp.js b/scp/js/scp.js
index c764a4c5299b577b0f2785d5de97134dbbfb68cb..6f7f502dd3fe2e1fe623fdeb169612b06ac54d00 100644
--- a/scp/js/scp.js
+++ b/scp/js/scp.js
@@ -275,28 +275,31 @@ $(document).ready(function(){
         });
     }
 
-    /* Datepicker */
-    getConfig().then(function(c) {
-        var df = c.date_format||'m/d/Y',
-            translation = {
-                'd':'dd',
-                'j':'d',
-                'z':'o',
-                'm':'mm',
-                'F':'MM',
-                'n':'m',
-                'Y':'yy'
-            };
+    $.translate_format = function(str) {
+        var translation = {
+            'd':'dd',
+            'j':'d',
+            'z':'o',
+            'm':'mm',
+            'F':'MM',
+            'n':'m',
+            'Y':'yy'
+        };
         // Change PHP formats to datepicker ones
         $.each(translation, function(php, jqdp) {
-            df = df.replace(php, jqdp);
+            str = str.replace(php, jqdp);
         });
+        return str;
+    };
+
+    /* Datepicker */
+    getConfig().then(function(c) {
         $('.dp').datepicker({
             numberOfMonths: 2,
             showButtonPanel: true,
             buttonImage: './images/cal.png',
             showOn:'both',
-            dateFormat: df,
+            dateFormat: $.translate_format(c.date_format||'m/d/Y'),
         });
         $(document).on('submit', 'form', function() {
             $('.dp', $(this)).each(function(i, e) {