[RESOLVED] Convert the variable value to time.
Hi guys how can I convert the value of a variable to time.
i.e
PHP Code:
$time=$dr[0] //btw $dr came from while($dr=mssql_fetch_row($r))
//so how can I convert the $time to time or datetime coz I have an If statement to check if $time is greater than some variable that holds another value that should be time
something like.
If($time > $etime)echo"You are late";
else echo" You are on time";
Thanks in advance.
Re: Convert the variable value to time.
How is the value stored in the database. I.e: in what format?
Re: Convert the variable value to time.
You can use strtotime() to convert most date/time formats to a timestamp.
Re: Convert the variable value to time.
If the time is stored in mysql date format, it would be less expensiveto convert it to a string in the query rather than in PHP.
Re: Convert the variable value to time.
Quote:
Originally Posted by visualAd
How is the value stored in the database. I.e: in what format?
It was stored as datetime format.
Re: Convert the variable value to time.
Thanks pen I used strtotime() function and it works.
btw thanks adam for the input.