Please do NOT post requests for help here. Use the Help forum for that.
  • Page:
  • 1

TOPIC:

formating of date-fields 2 years 1 month ago #1

  • thomas-w
  • thomas-w's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 1
hello,

i am looking for a software to show genealogical data on my website and found webtrees. because i have not found information on formatting date-fields, i hope to get information here.

unregistered users should not see the full date of person events, so i want to show them only the year. is it possible to customize the format of date-fields depending on user-groups? is that a general setting or is it possible to customize the format for each tree separate?

for your response many thanks in advance.

regards,
thomas

Please Log in or Create an account to join the conversation.

formating of date-fields 2 years 1 month ago #2

  • thomas52
  • thomas52's Avatar
  • Away
  • Premium Member
  • Premium Member
  • Western North Carolina
  • Posts: 912
You can change the format of the date to DD-MMM-YY or some other, but the individuals are either hidden (normally if living) or visible. You can show the names only of living persons or hide them completely, but that is about the only other option available.
"Failure is an amazing teacher." (L'échec est un professeur extraordinaire.)

Please Log in or Create an account to join the conversation.

formating of date-fields 2 years 1 month ago #3

  • fisharebest
  • fisharebest's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 14403
There is no setting or configuration for this. You'll need to make some code changes. If you don't have some basic PHP skills, then you are probably out of luck.

Date formats are language setting. e.g. Americans have "M D, Y" whereas Europeans have "D M Y", etc.

It is used in the "format localised date" function, which is here:
github.com/fisharebest/webtrees/blob/1.7...p/Date.php#L227-L229

You could add something like this
if (Auth::check() === false) {
  $date_format = 'Y';
}
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

formating of date-fields 1 year 7 months ago #4

Since I would also like to offer some genealogical information on my website, but on the other hand with certain restrictions, I copied the code Greg mentioned to the file Date.php. However, the result was not as expected. Now, on the personal page it shows a capital Y instead of the year, while in the right column the years are still visible (which is ok). Where is my mistake?

Andreas
Andreas

PHP 7.3.23, MySQL 5.6.49, Firefox 83.0
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by AS.

formating of date-fields 1 year 7 months ago #5

  • thomas52
  • thomas52's Avatar
  • Away
  • Premium Member
  • Premium Member
  • Western North Carolina
  • Posts: 912
You don't show us the CODE creating the "Y."
Check that the code reads -> $date_format = 'Y';
... and NOT -> $date_format = Y;
... or some other error.
"Failure is an amazing teacher." (L'échec est un professeur extraordinaire.)

Please Log in or Create an account to join the conversation.

formating of date-fields 1 year 7 months ago #6

  • fisharebest
  • fisharebest's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 14403
Try '%Y' instead of 'Y'
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

formating of date-fields 1 year 7 months ago #7

It works, thank you very much!
Andreas

PHP 7.3.23, MySQL 5.6.49, Firefox 83.0

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum