Skip Navigation

[Gelöst] converting date to time from a toolset custom field array

This support ticket is created vor 1 Jahr, 7 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

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

Zuletzt aktualisiert von guyA-2 vor 1 Jahr, 7 Monaten.

Assistiert von: Minesh.

Author
Artikel
#2591765
Screenshot 2023-04-12 at 11.56.34.png
Screenshot 2023-04-12 at 12.02.47.png

I'm using Toolset fields in my single-events.php template.

The start date and end date are displaying fine but when I try and use date() to turn the date into a time this is not dislaying anything other than 12:00 for both start and end time. You can see this on this page: versteckter Link underneath the image and heading.

I've attached a screenshot of my .php template.
I've also included a screenshot of the custom fields in the backend of WordPress.

Thanks in advance for your support!

#2591899

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details and FTP so that I can see whats going wrong there.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2591973

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Toolset stores the custom date field value as Unix Timestamp to the database.

$start_date_time = (types_render_field( 'start-date', array("output"=>'raw') ));
$end_date_time = (types_render_field( 'end-date', array("output"=>'raw') )); 

$start_time = date("g:ia", $start_date_time); 
$end_time = date("g:ia", $end_date_time); 

I've adjusted the code to get the time for start and end date within your single-events.php file as above. You can apply the same change wherever applicable.

I can see the correct time is displayed on frontend:
- versteckter Link

#2592281

My issue is resolved now. Thank you!