Solved

PHP: compare (<) two times given in MySQL text format

Posted on 2011-02-23
3
381 Views
Last Modified: 2012-06-21
I have echoed the two times (as an example) of a comparison i'm trying to do:

2011-02-22 16:42:05  <  2011-02-22 16:38:11

I've tried:  comparing the two text strings directly(!);   strcmp();   and  strtotime < strtotime

how is the best way to do this successfully?   (the strlen is always the same)

thanks
0
Comment
Question by:willsherwood
[X]
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
3 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 34963663
Just compare them directly like you are doing.
0
 

Author Comment

by:willsherwood
ID: 34963717
thanks, i retried, more confidently this time, and it worked.
(something else was amiss and i was blaming it on the  <  comparison!)

appreciated
0
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 34963792
$date1='2011-02-22 16:42:05';
$date2='2011-02-22 16:38:11';

if(strtotime($date1)  <  strtotime($date2))
{
    echo "ok";
}
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
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…

726 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