Skip Navigation

[Resolved] Field date and time

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
- 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/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 1 year, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2553827

Hi,
I would need to create a date and time field. However, in the wizard I only see the option to select date. How can I proceed?
Regards

#2554099

Hello,

You can follow our document to setup the custom date field, I have tried it in a fresh WP installation the latest version of Toolset plugins, it works fine.

See below test site:
Login URL: hidden link

Post field group with date field:
hidden link

More help:
https://toolset.com/course-lesson/creating-custom-fields/

#2554127

Hi,
perfect. One last question, I value this field from one of my functions. In the backend/frontend I always see the wrong timezone. Do I need to vary any settings?

From function I value it like this

$date = current_time('timestamp');
update_post_meta($bookingID, 'wpcf-date-time', $date);

My timezone is Europe/Rome. In the backend/fronted I always see it with one hour less.
Regards

#2554143

Can you reproduce the same problem in above test site?
I need a live website to test and debug

#2554147

Hi,
the value of my date field is handled by a php function. Unfortunately, I cannot craere this function in your test.
Regards

#2554157

The problem only exists in your website, and it is a custom PHP codes issue, can you copy/paste your custom PHP function here?

#2554213

Hi Luo Yang,
This is the code

$date = current_time('timestamp', 0);
update_post_meta($post_ID, 'test-date-1', $date);

Regards

#2554821

I have tried it in a fresh WP installation + the latest version of Toolset plugins, it works fine.

see below sandbox site:
Login URL: hidden link

1) Create a custom date field "date-time"
hidden link

2) Create a post and display above date field "date-time":
hidden link

3) Add the custom PHP codes you mentioned above into theme file "functions.php":
hidden link
line 69~71:

$bookingID = 34;
$date = current_time('timestamp');
update_post_meta($bookingID, 'wpcf-date-time', $date);

Test above post in frontend:
hidden link
It can display current date time correctly.

Can you reproduce the same problem in above test site?