WeBWorK Main Forum

Date Formatting

Date Formatting

by Thomas Wong -
Number of replies: 5
I am wondering if there is a global way of formatting dates in WebWork. The default setting appears to be MM/DD/YYYY, but this may be confusing for students who are used to DD/MM/YYYY formatting (especially here in Australia).

So far, I've edited the files to create custom date formats for
- what students see under homework sets
- hard copy generation

But I cannot see to find a work around for instructors, say in hmwk set editors.

Is there a global way to manage this? I apologise if this is a previous question. I'd appreciate if someone could link me to any relevant resources.

Thanks!
Tom
In reply to Thomas Wong

Re: Date Formatting

by Danny Glin -
I don't think there is a way to change it in the homework sets editor. IIRC The WeBWorK code parses those dates based on MM/DD/YYYY format, so changing that would be complicated.

The date picker is available for setting dates based on the calendar. Of course this doesn't help you when viewing the due dates in the homework sets editor.
In reply to Danny Glin

Re: Date Formatting

by Michael Gage -
The following note is in localOverrides.conf:

################################################################################
# Student Date Format
################################################################################

# Uncomment the following line to customize the format of the dates displayed to
# students. As it is written, the line below will display open, due and answer
# dates in the following format: Wed Jun 27 at 10:30am
# For all available options, consult the documentation for perl DateTime under
# "strftime patterns".
# $studentDateDisplayFormat="%a %b %d at %l:%M%P";


(Danny, I think you were the one who brought the date formatting issue up at one of our workshops -- ages ago. )

I haven't used it or tested it so YMMV. Report back and let us know if it does what you want. The variable is referenced in ProblemSet.pm and ProblemSets.pm

You should be able to set

# $studentDateDisplayFormat="%a %b %d at %l:%M%P";

in course.conf if you want to change the format for a single course.


In reply to Michael Gage

Re: Date Formatting

by Danny Glin -
http://webwork.maa.org/wiki/Dates,_Times,_and_Time_Zones). I have been using this for years. These settings only affect the Problem Sets and Problem pages (see . They are not used in the various instructor tools because WW is expecting a very specific date format in order to write to the database.

There is also a list of variables available to use in set header files for writing friendly dates.

It sounds like Tom has already discovered both of these two things. Making it work on pages where dates are edited was a more involved project. Though this was done before the advent of the javascript date picker, so now it may be easier to have the date picker pass the values directly to the perl module.
In reply to Danny Glin

Re: Date Formatting

by Michael Gage -
Thanks Danny.

I read the part about confusing students with dates not set according to the local pattern, but didn't realize that the student part of the problem
had been solved. I think that all of the dates that students see can be controlled.

I agree it would be harder to allow flexibility of date formatting
for instructors.
In reply to Michael Gage

Re: Date Formatting

by Thomas Wong -
Hi Michael, Danny,

Thank you very much for the information. I manage to locate the code snippets you mentioned and have made the appropriate changes.

I think I have everything on the student's side covered, but it seems like we have reached the same conclusion about things being more tricky on the instructors' side.

Thank you again for all your help.