Skip Navigation

[Resolved] converting date to time from a toolset custom field array

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
- 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)

This topic contains 3 replies, has 2 voices.

Last updated by guyA-2 1 year, 7 months ago.

Assisted by: Minesh.

Author
Posts
#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: hidden 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

Languages: English (English )

Timezone: 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

Languages: English (English )

Timezone: 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:
- hidden link

#2592281

My issue is resolved now. Thank you!