Skip to content

Commit

Permalink
Fixed issue: datefield from mssql database always contains milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Oct 23, 2018
1 parent 8d46780 commit 1c0bc38
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion application/controllers/admin/dataentry.php
Expand Up @@ -629,7 +629,10 @@ public function editdata($subaction, $id, $surveyid)
case "D": //DATE
$dateformatdetails = getDateFormatDataForQID($qidattributes, $surveyid);
if ($idrow[$fname['fieldname']] != '') {
$datetimeobj = DateTime::createFromFormat("!Y-m-d H:i:s", $idrow[$fname['fieldname']]);
$datetimeobj = DateTime::createFromFormat("Y-m-d H:i:s", $idrow[$fname['fieldname']]);
if($datetimeobj == null) { //MSSQL uses microseconds by default in any datetime object
$datetimeobj = DateTime::createFromFormat("Y-m-d H:i:s.u", $idrow[$fname['fieldname']]);
}
$thisdate = $datetimeobj->format($dateformatdetails['phpdate']);
} else {
$thisdate = '';
Expand Down

0 comments on commit 1c0bc38

Please sign in to comment.