Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

compare two timevalues using php windows (without strptime)

Posted on 2011-02-28
6
373 Views
Last Modified: 2012-06-21
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
Comment
Question by:rgb192
  • 3
  • 3
6 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35001409
Did you look at the comments under the function definition ?
Doesn't any of the fit ?
0
 

Author Comment

by:rgb192
ID: 35001470
i checked comments under function definition and none fit


maybe it needs a string replace

P2DT16H2M40S
sometimes there is 1digit
(2minutes)
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35001539
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:rgb192
ID: 35001581
P2DT16H2M40S

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

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 35004376
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
 

Author Closing Comment

by:rgb192
ID: 35007525
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question