Skip Navigation

[Resolved] display current date in View or CRED form

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by eliseD-2 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#477161

This seems like such a simple thing, but I can't figure out how to do it. I am attempting to create a shortcode by myself for the first time, and I am failing horribly.

All I am trying to do is to display the CURRENT date in a view in the format such as:

January 1, 2017

When I use this shortcode:

add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return time();
}

It displays the current date as a timestamp (I think).

So I tried this:

add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return ( string $format [, int $timestamp = time() ] );{
$format = l, F j, Y;
}
}

But clearly I have the syntax wrong because it throws an error.

Ideas?

Thanks!

Elise

#477276

Dear Elise,

I assume you are going to use PHP date() function to display current date, please try to modify your PHP codes as this:

add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return date( 'l, F j, Y', current_time( 'timestamp' ));
}

And test again.

More help:
https://codex.wordpress.org/Function_Reference/current_time
hidden link

#477556

That worked perfectly - thanks so much!

Elise

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