Skip Navigation

[Resolved] custom field that displays date and time using php

This support ticket is created 7 years, 1 month ago. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Shane 7 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#503768

I am trying to use PHP to display the current date and time.

I then want to use the same approach to get the last modified date of a post/page.

I've inserted this function into my child theme and was expecting it to then give me a shortcode that I could use in types.

add_shortcode('date_time');
function date_time() {

<?php the_time('l, j F Y   g:ia') ?>

$date_time = 'Date and Time Output';
return $date_time;
}

Instead, I got an error. Not working.

Please help. What am I doing wrong?

#503819

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi COOP,

Thank you for contacting our support forum.

There a few issues with the shortcode declaration.

I would recommend using this tool to generate your shortcodes.
hidden link

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.