Navigation überspringen

[Gelöst] Field date and time

This support ticket is created vor 3 years, 3 months. 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.

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 -

Zeitzone des Unterstützers: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 7 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 3 years, 3 months.

Assistiert von: Luo Yang.

Author
Artikel
#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: versteckter Link

Post field group with date field:
versteckter 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: versteckter Link

1) Create a custom date field "date-time"
versteckter Link

2) Create a post and display above date field "date-time":
versteckter Link

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

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

Test above post in frontend:
versteckter Link
It can display current date time correctly.

Can you reproduce the same problem in above test site?