Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

compare two timevalues using php windows (without strptime)

compare these two time values

P2DT16H38M54S


P2DT16H38M56S



if ($first>$second) do something


Can not
Parse the values using strptime function.
http://www.php.net/manual/en/function.strptime.php 
because
Note: This function is not implemented on Windows platforms.


0
rgb192
Asked:
rgb192
  • 3
  • 3
1 Solution
 
Lukasz ChmielewskiCommented:
Did you look at the comments under the function definition ?
Doesn't any of the fit ?
0
 
rgb192Author Commented:
i checked comments under function definition and none fit


maybe it needs a string replace

P2DT16H2M40S
sometimes there is 1digit
(2minutes)
0
 
Lukasz ChmielewskiCommented:
Could you explain some string format to date as I'm not familiar with it ? We could work on that maybe fitting the regular expressions ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
rgb192Author Commented:
P2DT16H2M40S

P-> I dont know
DT->Days
H->Hours
M->Minutes
S->Seconds
0
 
Lukasz ChmielewskiCommented:
Take a look at this:

<?php
    $var1 = "P2DT16H38M54S";
    $var2 = "P2DT16H38M56S";
    
    echo"date1: $var1<br />date2: $var2<br />";
        
    $date1 = implode("",preg_split("/[a-zA-Z]/",$var1));
    $date2 = implode("",preg_split("/[a-zA-Z]/",$var2));    
    
    //print_r($date1);
    //print_r($date2);
    
    if($date1 <= $date2){
        echo"date1 less or equal than date2";
    }else{
        echo"date2 less than date1";
    }
?>

Open in new window

0
 
rgb192Author Commented:
Thanks,

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_26855251.html

I have a similar question
ebay gives time left in the format

P2DT16H2M40S
P20DT6H2M4S

P-> I dont know
DT->Days
H->Hours
M->Minutes
S->Seconds
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now