Corrected logDatetime conversion code