diff --git a/js/bootstrap-datetimepicker.js b/js/bootstrap-datetimepicker.js
index <HASH>..<HASH> 100644
--- a/js/bootstrap-datetimepicker.js
+++ b/js/bootstrap-datetimepicker.js
@@ -515,9 +515,10 @@
         left = offset.left;
       }
 
-      if(left+220 > document.body.clientWidth){
-                  left = document.body.clientWidth-220;
-              }
+      var bodyWidth = document.body.clientWidth || window.innerWidth;
+      if (left + 220 > bodyWidth) {
+        left = bodyWidth - 220;
+      }
 
       if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {
         top = offset.top - this.picker.outerHeight();
Fixed issue where document.body.clientWidth was 0 when datetimepicker is shown in modal and overflow:hidden is specified which caused picker to render off-screen.