Skip Navigation

[Resolved] Displaying custom field which is a date +1 day

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

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 7 replies, has 2 voices.

Last updated by matthewL-7 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1704967

Hi

Is there a way to print a custom field to the page but with +1 day easily?

The issue is I want to add a "Add to google calendar" button but the google calendar API needs you to provide the end date, a day after the end date (oddly).

Thanks.

#1705251

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

In your case to add +1 day to your current custom date field, you need to write custom shortcode where you should pass your current custom date field value and add the related date manipulation code to add +1 day to your current field date value.

Following links may help you:
=> https://stackoverflow.com/questions/1394791/adding-one-day-to-a-date
=> https://stackoverflow.com/questions/16018629/php-add-1-day-to-date-format-mm-dd-yyyy/16018697

More info:
=> https://toolset.com/documentation/adding-custom-code/how-to-create-a-custom-shortcode/

If you do not know how to do it, if you can share test page and access

#1712389

Hey Minesh

I have tried to get my head round this but can't manage it, as I don't know how to get the custom field date variable to add the 1 day to it in PHP.

Happy to provide access to this so you can take a look, can you send a form with access details please?

Thank you for your help with this!

#1713589

Minesh
Supporter

Languages: English (English )

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

Sure - you can send me the problem URL and access details and I am happy to look at it.

*** 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.

#1714875

Minesh
Supporter

Languages: English (English )

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

Can you please clarify where exactly you want to add +1 day to what field as well as where you are displaying that field?

Can you please share all this required information.

#1715857

Yeah of course Minesh.

So on this page: hidden link

You will see an "Add to Calendar" link, this link has Toolset custom fields in it to insert the Start and End Date fields of the event.

G Cal links require the end date to be the day after (no idea why) so I am trying to have the end date outputted as whatever is set +1 day.

The specific name of the Toolset custom field is "end-date" or "wpcf-end-date".

Thanks.

#1715863

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've added the following shortcode to "Custom Code" section offered by Toolset:

function func_get_enddate_plus_oneday($atts){  
     
   return date('Ymd',strtotime($atts['enddate'] . ' +1 day'));
}  
add_shortcode('get_enddate_plus_oneday', 'func_get_enddate_plus_oneday'); 

And adjusted the shortcode within your link as given under:

 <a href="<em><u>hidden link</u></em> field='start-date' style='text' format='Ymd'][/types]/[get_enddate_plus_oneday enddate='[types field='end-date' style='text' format='Ymd'][/types]']&details=For+details,+visit+event+website+here:+[types field='event-website' output='raw'][/types]&location=[types field='event-city'][/types] [types field='event-country'][/types]" target="_blank" rel="noopener noreferrer"><img src="<em><u>hidden link</u></em>" alt="Calendar icon" height="14" width="14"> Add to Calendar</a>

I can see its working as expected. Can you please confirm it works at your end as well.

#1716367

Awesome thank you! 🙂 Much appreciated. Have an awesome week.

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