Problem:
Client has created a custom shortcode to set the default value for a custom date field in a Toolset Form, but it is not allowing for the time zone.
Solution:
An updated shortcode to show the current date/time adjusted for the time zone that can be used to set the default value of a date field is:
add_shortcode( "now", function(){ // get UTC offset for current WP timezone $offset = get_option('gmt_offset'); return time() + $offset * 60 * 60; });
Relevant Documentation:
https://toolset.com/documentation/adding-custom-code/
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 4 replies, has 2 voices.
Last updated by 6 years, 2 months ago.
Assisted by: Nigel.