Skip Navigation

[Resolved] date format without day, entering and displaying

This thread is resolved. Here is a description of the problem and solution.

Problem:

A user asked about the best approach for sharing date information without a specific day.

Solution:

Guided that it is possible to show the date type field's output in any date/time format, using the "format" attribute.

However, storing the month and year without the actual day is challenging as the Toolset's date type field stores the selected date in a UNIX timestamp format ( ref: https://en.wikipedia.org/wiki/Unix_time ).

This format stores the exact date and time reference, in which the day component can't be skipped.

For this reason, if you just need to store and display month and year with the posts and don't plan to perform any date based search/filtering on these, it would be better to replace a single date type custom field, with two select type custom fields, one for the month and the other for the year.

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/functions/#date

This support ticket is created 2 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by scottB-17 2 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2323205

In a form, asking for a date, I want to require only year and month, not day. I also want to display only year and month in a view. Is that possible? I don't see where to set date format. Thank you.

#2323599

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

It is possible to show the date type field's output in any date/time format, using the "format" attribute:
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#date )

For example, to show it in the "Month, Year" format, you can use the shortcode:


[types field='date-field-slug' style='text' format='F, Y'][/types]

However, storing the month and year without the actual day is a bit complicated. The Toolset's date type field stores the selected date in a UNIX timestamp format ( ref: hidden link ).

This format stores the exact date and time reference, in which the day component can't be skipped.

For this reason, if you just need to store and display month and year with the posts and don't plan to perform any date based search/filtering on these, it would be better to replace a single date type custom field, with two select type custom fields, one for the month and the other for the year.

regards,
Waqar

#2324143

Thank you, as always.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.