Skip Navigation

[Résolu] Split: shortcode of rfg datum-und-uhrzeit only have 1 entry – how to display date and time

This support ticket is created Il y a 2 années et 9 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.

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
- 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 réponses, has 2 voix.

Last updated by alexd-6 Il y a 2 années et 9 mois.

Assisted by: Minesh.

Auteur
Publications
#2108373

Hey Minesh,

one thing about the datum-und-uhrzeit field in rfg.

1. why doesnt it show the time? I used date and time in rfg field
2. can i compare it to actual date and time -> if it in paste i would remove it

thx - alex

#2108379

Minesh
Supporter

Languages: Anglais (English )

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

Hello. Thank you for contacting the Toolset support.

1. why doesnt it show the time? I used date and time in rfg field
==>
As you are using the Types PHP API function: types_render_field
- https://toolset.com/documentation/customizing-sites-using-php/functions/#date

It supports the attribute format where you can set in what format you want to display the date and time. You can chose your desired format:
- https://wordpress.org/support/article/formatting-date-and-time/

2. can i compare it to actual date and time -> if it in paste i would remove it
Yes - you can compare it with the PHP function time() and use if condition and convert your existing date value to timestamp and compare it manage it accordingly.

#2108389

Hi,

the date i can set zu timestamp, but not the parts of array. Is the reason the german date format?

this is date/time right now as timestamp:
$today = date("j. F Y H:i");
$todaytimestamp = strtotime($today);

$one = strtotime($temp[0]);

here ist my funcion again 😉 - i would it only $one and $two as timestamps;

function myownfunc( $atts ) {
    $post_id = $atts['postidmy'];
    $fieldvalues = toolset_get_related_posts( get_the_ID(), "termine-veranst", array( 'query_by_role' => 'parent', 'return' => 'post_object'));
    $today = date("j. F Y H:i");
    $todaytimestamp = strtotime($today);
    $temp = array();
    foreach ($fieldvalues as $fieldvalue) {
    $partone = types_render_field('datum-und-uhrzeit', array('post_id' => $fieldvalue->ID));
    $temp[] = $partone;
    $one = strtotime($temp[0]);
    $two = strtotime($temp[1]);
        }
    return "".implode(" - ",$temp)."<br> --- " .$one." - " . $two . "<br>" . $todaytimestamp;
    }
    add_shortcode( 'datetime', 'myownfunc' );

thx - alex

#2108425

Minesh
Supporter

Languages: Anglais (English )

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

I do not get what you are saying. Can you please share example whats wrong with the code you shared and whats your expected output?

#2108427

Hi - sorry,

i mean i cant format the array $temp get formated in timestamp.

if i try to format e.g. $temp[0] to timestamp like: $one = strtotime($temp[0]);

i dont have some output.

Is it possible to format direct in array $temp all dates in timestamp ?

i hope thats clear enough.

thx - alex

#2108429

Minesh
Supporter

Languages: Anglais (English )

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

what if you try to use:

$temp[] = strtotime($partone);

Then all the values in array will be stored as timestamp.

#2108471

hi,

this dont work - $temp[] = strtotime($partone);

its empty in:

return "".join(" - ",$temp) ;

thx - alex

#2108527

I dont know but - now it works! - i think it was a corrupt php installation by hoster..

My issue is resolved now. Thank you!

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