Skip to Content Skip to Menu

[SOLVED] Date field format in substitutions

2 years 7 months ago - 2 years 6 months ago #329195 by tastyracer
Hi, I'm trying to get a date field to display in "jS F Y" format ('28th February 2022') when using substitutions in an article. I have entered this as custom in the field's Parameters>Display and it renders perfectly in the user's profile, but it still only shows the raw value (correct date but as yyyy-mm-dd) in the substution.

I've tried:
[cb:userdata field="MYDATEFIELD" /]
[cb:userdata field="MYDATEFIELD" reason="profile" /]
[cb:userdata field="MYDATEFIELD" format="jS F Y" /]

It works if I create a tab for the date field only and use [cb:usertab tab="TABID" /] substitution, but I'd prefer not to if I can avoid it.

In same article I'm also displaying today's date in same format using:
[cb:date format="jS F Y" /]

...which works nicely

Can you point me in the right direction?
Last edit: 2 years 6 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 7 months ago - 2 years 6 months ago #329199 by krileon
Replied by krileon on topic Date field format in substitutions
[FIELD_NAME] and [cb:userdata field="FIELD_NAME" /] substitutions are always raw values. You're needing the formatted value which requires the usage of the [cb:userfield field="FIELD_NAME" /] substitution format. So you should be able to just replace your userdata substitution usage with userfield usage and will display how you're wanting. More details regarding this can be found in our substitution tutorial below.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb

Another neat trick is our nested substitutions. Nested substitutions are supported for date substitutions. So something like the below also works for custom formatting at only that location.

[cb:date format="jS F Y" date="[FIELD_NAME]" /]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 2 years 6 months ago by krileon. Reason: fixed typo

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

  • dhphllps
  • dhphllps
  • OFFLINE
  • Posts: 40
  • Thanks: 5
  • Karma: 1
2 years 6 months ago #329363 by dhphllps
Replied by dhphllps on topic Date field format in substitutions
I'm trying to format the expiry date in a CBSubs mailer. I tried using the syntax you suggested:

[cb:date format="F j, Y" data="[SUBSCRIPTION_EXPIRY_DATE]" /].

but the resulting emails came through as:

[cb:date format="F j, Y" data="06/04/2022" /].

Is there another setting somewhere that I'm missing to format expiry date in a CBSubs mailer?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 6 months ago - 2 years 6 months ago #329375 by krileon
Replied by krileon on topic Date field format in substitutions
You are setting "data" and not "date". So just looks like a minor typo. The below should work fine.

[cb:date format="F j, Y" date="[SUBSCRIPTION_EXPIRY_DATE]" /]

Fixed typo in my post above. Sorry about that!


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 2 years 6 months ago by krileon.

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

  • dhphllps
  • dhphllps
  • OFFLINE
  • Posts: 40
  • Thanks: 5
  • Karma: 1
2 years 6 months ago - 2 years 6 months ago #329376 by dhphllps
Replied by dhphllps on topic Date field format in substitutions
Thank you!
Last edit: 2 years 6 months ago by dhphllps.

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

Moderators: beatnantkrileon
Powered by Kunena Forum