Results 1 to 6 of 6

Thread: [RESOLVED] Convert the variable value to time.

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Resolved [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.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,907

    Re: Convert the variable value to time.

    How is the value stored in the database. I.e: in what format?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Convert the variable value to time.

    You can use strtotime() to convert most date/time formats to a timestamp.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,907

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    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.

  6. #6

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Convert the variable value to time.

    Thanks pen I used strtotime() function and it works.

    btw thanks adam for the input.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width