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
Minesh
Supporter
Languages:
English (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.
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
Minesh
Supporter
Languages:
English (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?
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
Minesh
Supporter
Languages:
English (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.
hi,
this dont work - $temp[] = strtotime($partone);
its empty in:
return "".join(" - ",$temp) ;
thx - alex
I dont know but - now it works! - i think it was a corrupt php installation by hoster..
My issue is resolved now. Thank you!