diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php
index 1bdabb2b60114330378b0ab278a3eb2719e876f4..1d88eb6f7cfde7de8d686ae1b4a12b2af29bce15 100644
--- a/CRM/Utils/Date.php
+++ b/CRM/Utils/Date.php
@@ -369,7 +369,7 @@ class CRM_Utils_Date {
 
         $hour24 = (int) substr($dateString, 11, 2);
         $minute = (int) substr($dateString, 14, 2);
-        $second = (int) substr($dateString, 16, 2);
+        $second = (int) substr($dateString, 17, 2);
       }
       else {
         $year = (int) substr($dateString, 0, 4);
diff --git a/tests/phpunit/CRM/Utils/DateTest.php b/tests/phpunit/CRM/Utils/DateTest.php
index 8ab957fbbe41ee5f4941190391ed007aa17b4ffb..b68f1b39b8a10b57dce95ecadf469769a504bb11 100644
--- a/tests/phpunit/CRM/Utils/DateTest.php
+++ b/tests/phpunit/CRM/Utils/DateTest.php
@@ -270,6 +270,7 @@ class CRM_Utils_DateTest extends CiviUnitTestCase {
     $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%p"), "pm");
     $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%P"), "PM");
     $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%Y"), "2018");
+    $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%s"), "44");
   }
 
   /**