Certificate Date Format

Certificate Date Format

by Rhonda Goetz -
Number of replies: 6
Hello,

I would like the date on my certificate report to be mm/dd/yyyy, 00h:00m

Right now it is this: Friday, 7 May 2010, 07:29 PM

Which makes it completely unsortable. Does anyone have a solution for this?

Thank you, Rhonda
Average of ratings: -
In reply to Rhonda Goetz

Re: Certificate Date Format

by Raymond Fürst -
Hi Rhonda,

the date format can be switched using the date format selector in the text options area.

If the predefined formats do not suit you: The actual appearance of the format is coded in the certificate.php-files in %moodledir%/mod/certificate/type/%typename%

In the beginning of these files there is a section marked with // Date formatting - can be customized if necessary. For each option in the date format selector there is a line that actually formats the date using the function strftime().

I think strftime() is a standard function in php. It uses %-codes for formatting, such as %Y for the year in 4 digits. %m/%d/%Y should deliver the year as you want, i'm not sure what %-codes are used for hours and minutes.

Average of ratings: Useful (1)
In reply to Raymond Fürst

Big Mega-Oops

by Raymond Fürst -
Hi Rhonda,

please disregard my previous answer. I thought you wanted to change the format of the date printed on the certificate itself.

To change the appearence of the date in the report view, you have to change the file %moodledir%/mod/certificate/report.php

In this file, look for a line like
$date = userdate($user->certdate);

The userdate function here turns the numeric date stored in the database into a nicely formatted date. If no second parameter is given, the normal format for your locale is used ("Friday, the 4th ...").

You can override the format by adding a format string as a parameter:
$date = userdate($user->certdate, "%m/%d/%Y, %Hh:%Mm");

I'm not sure what kind of quotes are right here. Check http://php.net/manual/en/function.strftime.php for possible format code characters

Another hint:
Look for a line beginning with $sqlsort
$sqlsort = 's.certdate ASC';
sorts the certificate by date
Average of ratings: Useful (2)
In reply to Raymond Fürst

Re: Big Mega-Oops

by Rhonda Goetz -
Thank you for that information - the dates were changed in Moodle and that is great - the problem is that the excel export still reflects the old Friday, June 2, 2010 thing.

Any ideas?
In reply to Rhonda Goetz

Re: Big Mega-Oops

by Raymond Fürst -
There is another invocation of userdate($user->certdate) in the part of report.php that generates the spreadsheet export.

Alternatively, there is a function in excel that converts a string containing a date into a real date format.
In reply to Raymond Fürst

Re: Big Mega-Oops

by Rhonda Goetz -
What is the function in Excel? It is not working in the report.php
In reply to Rhonda Goetz

Re: Big Mega-Oops

by Raymond Fürst -
There is a function called DATEVALUE() in excel. It is a worksheet-function, so you can enter =DATEVALUE("01.01.2010") to turn this string into the corresponding excel date value. You can apply this function to an excel worksheet after the export from the report.

In may be necessary to strip away the daynames first.


Patching the excel-export part of report.php might force the report to a certain format.