Skip Navigation

[Résolu] converting date to time from a toolset custom field array

This support ticket is created Il y a 1 année et 7 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par guyA-2 Il y a 1 année et 7 mois.

Assisté par: Minesh.

Auteur
Publications
#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: lien caché 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

Les langues: Anglais (English )

Fuseau horaire: 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

Les langues: Anglais (English )

Fuseau horaire: 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:
- lien caché

#2592281

My issue is resolved now. Thank you!