Best way to set date format to dd-mm-yy

Permalink
Could you please indicate best way to set date format to other than american mm-dd-yy?
Where should I set the code for 5.7 since site.php is gone.
I tried setting up language and locale but that did not change the date format
I will be using a datepicker with the built in form date selection.
Thanks

 
mlocati replied on at Permalink Reply
mlocati
Where exactly do you need this date format?

Using Core::make(''helper/form/date_time')->datetime(...) should already show the date/time format for the currently active language
clipi replied on at Permalink Reply
I have a form made with the build in tools and customer need to enter the date with the datepicker. Not only I need to change the date format and language but also day start on monday.
Have no idea where to enter the code for that since site.php is gone.
Thanks
Kiesel replied on at Permalink Reply
Would like to know the same. Everything seems to work with localization, but the datepicker / $dtt->date() seems to ignore it and stay on the month/day/year setting used in the US instead of the day.month.year used in Europe.
kfog replied on at Permalink Reply
kfog
trying to do the same with the new addon "calender" it shows as mm-dd-yy and AM / PM.
can that be changed?

i also want to change the names of months and weekdays. where can change that?
i also cannot find it on proevent.
we need the german words.

if anybody finds out, please share...

thanks a lot in advance.
keith
Kiesel replied on at Permalink Reply
What I know is, that depending on the language that is set certain things change. So if User A logs into concrete5 with British English, the dates will be set like dd/mm/yyyy. If he logs in with US English, the dates will be like mm/dd/yyyy. With German it will be dd.mm.yyyy.

That is kind of a solution that most likely works for most people. But I have users that would like to work with English and dd.mm.yyyy as they are all used to dd.mm.yyyy.

And I don't see how that is possible now? I much prefered the 5.6 version where you were able to just put the way you wanted it into the site.php file and it was everywhere the same.

How am I even supposed to change every different possible date format into a unix timestamp now? Mass confusion....
clipi replied on at Permalink Reply
Very frustrating issue for international users. Nobody seem to know how to change the date format or customize it in 5.7?
clipi replied on at Permalink Reply
Very frustrating issue for international users. Nobody seem to know how to change the date format or customize it in 5.7?
sparrowwebservices replied on at Permalink Reply
sparrowwebservices
I too need to know the answer to this
sparrowwebservices replied on at Permalink Reply
sparrowwebservices
I think I have cracked it!!!

NOTE/CAUTION: This involves editing a core concrete file but at the moment is the only way i can find to do it and hasn't broken anything that i can find as of yet.

Locate the file called Date.php (concrete/src/Localization/Service/Date.php)

Find the function called datetime
public function datetime($prefix, $value = null, $includeActivation = false, $calendarAutoStart = true)

On line 159 you should find:
dateFormat: ' . $jh->encode($dh->getJQueryUIDatePickerFormat(t(/*i18n: Short date format: seehttp://www.php.net/manual/en/function.date.php... */ 'n/j/Y'))) . ',

Towards the end of that line you will see the 'n/j/Y' which equates to (for todays date) 4/6/2016.

You can put any PHP date format into here and this is what will be displayed in the date picker widget. I have chosen to go with 'd/m/Y' which will display as 04/06/2016.

A full list of the PHP date/time formats can be found at http://php.net/manual/en/function.date.php...

NOTE: ONLY put in the format for the date section into here. If you try to put any time section formats it breaks the date/time widget.
beltmanjr replied on at Permalink Reply
Thanks for the answer.
It seems
dateFormat: ' . $jh->encode($dh->getJQueryUIDatePickerFormat(t(/*i18n: Short date format: seehttp://www.php.net/manual/en/function.date.php... */ 'n/j/Y'))) . ',

is missing from the file called Date.php (concrete/src/Localization/Service/Date.php).

Any ideas?
eyedea123 replied on at Permalink Reply
The file where that line is should be /concrete/src/Form/Service/Widget/DateTime.php
JackVanson replied on at Permalink Reply
I'm am having this issue and ive done all of the above and still no luck. the US date format will not change to UK.

I have US users and UK users all set up with the right time zone but no change for anyone.

Please help me.
Gondwana replied on at Permalink Reply
Gondwana
I think this is a bug in c5. I reported it at
https://www.concrete5.org/developers/bugs/8-1-0/datetime-cant-be-loc...
but it doesn't seem to be getting much attention.

Perhaps you could +1 that report and maybe add a comment.

I did manage to force the format to UK/Australian format for ALL of my site's users via a God-awful hack.
beltmanjr replied on at Permalink Reply 1 Attachment
Although I can't find the original post anymore, I've attached a zip file that contains a en-GB directory (and subdirs) and some messages.mo file. Placing this directory in the concrete application/languages dir will add the option to select 'British English (United Kingdom) under Systems & Settings/Languages. Selecting that option should change the date time format to the UK format.
JackVanson replied on at Permalink Reply
Hi I spoke to mlocati yesterday and he said we will take a looking into it and get back to me ASAP. It is most definitely a bug within C5 as i tested on there demo site that you can install and try out before you download.
Gondwana replied on at Permalink Reply
Gondwana
I suppose, ideally, the date format should adapt to the locale of the logged-in user, rather than being a site-wide thing.
headland replied on at Permalink Reply
headland
We use another solution for this problem on some websites. We don't like core hacking. The date widget is based on jquery ui datepicker. That means, you can change datepicker options after initialization:
// output date field
<?php echo $datepicker->date('fieldname', '2017-07-12'); ?>
<script>
$(document).ready(function() {
   // manipulate the datepicker format to german formatting
   // NOTE: your custom fieldname must have the addition "_pub" (check element inspector)
   $( "#fieldname_pub" ).datepicker( "option", "dateFormat", "dd.mm.yy" );
});
</script>


hope that will help ... toni
surefyre replied on at Permalink Reply
surefyre
Why is there not simply a date format string option under timezone or language?

Can't believe I'm going to have to hack foreign date format to UK when I'm set to London and British English.

Even Wordpress allows you to pick a string.
surefyre replied on at Permalink Reply
surefyre
Why is there not simply a date format string option under timezone or language?

Can't believe I'm going to have to hack foreign date format to UK when I'm set to London and British English.

Even Wordpress allows you to pick a string.
JackVanson replied on at Permalink Reply
I have fixed this issue.

The issue was in the English (United Kingdom) mo file the date format was set to the US format. I have now changed this to the UK format.

All you need to do is download the latest mo file from:https://translate.concrete5.org/translate/package/concrete5...

This will change the date format within the C5 Admin for English (United Kingdom) users

Jack
owl replied on at Permalink Reply
owl
Thanks Jack. Sounds wonderful. Forgive my ignorance but once downloaded to my computer, where should I upload it to and how should I implement it?
JackVanson replied on at Permalink Reply
I'm pretty sure you update this file.

application/languages/en_GB/LC_MESSAGES/messages.mo

Just rename the downloaded file to messages.mo. Try it and see.

I'd keep a backup of the old messages.mo just in case.

Jack
owl replied on at Permalink Reply
owl
Tried this. No harm but not solved the problem.
Let's be specific:
c5-8.1.0 Private site - Members Only. PHP time setting - Europe/London.
c5 Defaults: Language - British English (United Kingdom); Timezone - London; no user-selection of alternatives.
Task: Create DoB field in user profiles.
Method: Members> Attributes> ADD Date/Time> Ask user for Date Only.
Fine so far.
Admin goes to Add New User OR User goes to Update Profile, click in DoB box, pop-up date-picker works fine, saves and returns date as 28/04/1990 - Great!
BUT try typing 28/04/1990 directly into the box as a quick alternative to scrolling through the picker and it fails and returns today's date!
- Type 4/28/1990 in the box and it accepts it and returns 28/04/1990.
Therefore the problem appears to lie in the date-picker widget.
Bad enough for me but it will completely flummox our site members!
Any help gratefully received.
darbie replied on at Permalink Reply
darbie
Hi I want to change it for other language. Which Original String is it please?