Posts Tagged ‘Mo’

DateTime Format in Moodle

Posted: August 3, 2012 in Uncategorized

For our Moodle site, I had to add a new user profile field called joining date. I was using upload user utility in Moodle to load data from CSV file and it wouldn’t load the date correctly in the system. After struggling for four days, I finally found out that Moodle stores datetime in unix time or epoch time.  I used following formula for converting date  to epoch time where date was in mm/dd/yyyy format.
Formula for Excel : Moodle Date =((Date -25569) * 86400) + 21600

Formula for using in select in MSSQL: DATEDIFF(s,‘1970-01-01 00:00:00’, [YourdtInStdUSformat])

Formula for converting from epoch time to mm/dd/yyyy format in sql in MSSQL:

dateadd(s ,yourDateInEpocFormat , ‘1970-01-01’)


This worked perfectly.