Flat file (CSV) from Wednesday, 31 December 1969, 6:00 PM

Flat file (CSV) from Wednesday, 31 December 1969, 6:00 PM

by Jim Angel -
Number of replies: 4
I have updated multiple times to various versions of the latest Moodle and this problem never appears to go away or be solved...

PROBLEM: Uploading users via Flat file defaults to epoch 0 (or in my case, minus a few hours because of the timezone).

You can see the following people also had issues similar issues with no serious reply or resolution:

Any thoughts?

Average of ratings: -
In reply to Jim Angel

Re: Flat file (CSV) from Wednesday, 31 December 1969, 6:00 PM

by Jim Angel -
In [moodlepath]/enrol/flatfile.php

I can see the following 'if' statement that appears to enter the epoch date using the php function 'time();':

if ($timestart > time() and $buffer_if_future) {
            // Populate into enrol_flatfile table as a future role to be assigned by cron.
            // Note: since 2.0 future enrolments do not cause problems if you disable guest access.
            $future_en = new stdClass();
            $future_en->action       = $action;
            $future_en->roleid       = $roleid;
            $future_en->userid       = $user->id;
            $future_en->courseid     = $course->id;
            $future_en->timestart    = $timestart;
            $future_en->timeend      = $timeend;
            $future_en->timemodified = time();
            $DB->insert_record('enrol_flatfile', $future_en);
            $trace->output("User $user->id will be enrolled later into course $course->id using role $roleid ($timestart, $timeend)", 1);
            return;
        }

If I hear nothing back, my next steps will be trying to set time(); as a variable ($timestart) and re-run the flat file.

(I have tested from my server cli that time(); does return an accurate result.)

In reply to Jim Angel

Re: Flat file (CSV) from Wednesday, 31 December 1969, 6:00 PM

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

2 questions:


What is your date.timezone php.ini setting?

You can consult it in admin/phpinfo.php - date

date

date/time supportenabled
"Olson" Timezone Database Version0.system
Timezone Databaseinternal
Default timezoneEurope/Amsterdam


Did you modify some strings (language customization) in the langconfig file?

Average of ratings: Useful (1)
In reply to Renaat Debleu

Re: Flat file (CSV) from Wednesday, 31 December 1969, 6:00 PM

by Jim Angel -

Good point! I checked it out and did not see a default timezone set under the "date" area. I've updated that and we'll see if that works.

I did not modify any strings in the language customization file.

Thanks for the advice, hope it works!

In reply to Jim Angel

Re: Flat file (CSV) from Wednesday, 31 December 1969, 6:00 PM

by Jim Angel -

That appears to have done the trick. Thank you!