Navigation überspringen

[Gelöst] Format field from FooEvents

This support ticket is created vor 4 Jahren, 8 Monaten. 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
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: Africa/Casablanca (GMT+01:00)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Marcel vor 4 Jahren, 8 Monaten.

Assistiert von: Jamal.

Author
Artikel
#1573635

Tell us what you are trying to do?
I use [wpv-post-field format='d.m.Y' name='WooCommerceEventsDate'] and would like to have 03.04.2020 but I get 2020-04-03

#1574209

Hello and thank you for contacting the Toolset support.

I suspect that the FooEvents plugin stores date as a string. Toolset on the other side stores date as a timestamp.
If it is the case you can use a similar solution to this one https://toolset.com/forums/topic/transforming-content-in-number-field-as-price/#post-611859
And use date functions to build a valid date from the stored string, then to format the date into the format you desire.
- versteckter Link
- versteckter Link
The shortcode will be used as:

[your_shortcode date="[types field='WooCommerceEventsDate' format='FIELD_VALUE'][/types]"]

I hope this helps. Let me know if you have any questions.

#1574839

Hi Jamal

Got it working like this

function format_eventdate( $atts ) {
	  setlocale(LC_TIME, 'de_DE');
    extract( shortcode_atts( array(
    'eventdate' => '0'), $atts) );
  
    $date = strtotime($price);
    $date = date('D d.m.Y',$date);
    $weekdays = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
    $wochentage = array("MO", "DI", "MI", "DO", "FR", "SA", "SO");
    $date = str_replace($weekdays, $wochentage, $date);
    return $date;
}
add_shortcode('format_eventdate', 'format_eventdate');

Thanks a lot
Marcel

#1574841

My issue is resolved now. Thank you!