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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s