Reputation:
I have some troubles in dateinterval in php. Is there any option to remove digits after dot, or just convert them? I mean I have PT1H1.836S, and I would like to receive PT1H2S for example
$str = 'PT1H1.836S';
$arr = new DateInterval($str);
Upvotes: 0
Views: 43
Reputation: 703
Hello you can try somthing like that.
$str = "PT1H1.836S";
$xx1 = explode( '.', $str );
$xx2 = preg_replace('/[0-9]+/', '', $xx1[1] );
$final = $xx1[0].$xx2;
print_r($final);
Upvotes: 0