#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    14
    Rep Power
    0

    Problem in date time conversion


    hi experts

    i hope your are all fine.

    my problem is . i want to display date and time on my php page after fetching it from oracle database. i wrote the code as

    Code:
    echo date('d-M-y h:i:s',strtotime($V_CREATION_DATE));
    its output is : 16-Dec-12 12:00:00
    but the original date time stored in table is :16-Dec-12 11:44 AM

    no matter what the time is . it always shows 12:00:00.

    please suggest a solution.

    thanks in anticipation.

    Regards
    Athar
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,303
    Rep Power
    9400
    What does
    PHP Code:
    print_r($V_CREATION_DATE); 
    output?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    14
    Rep Power
    0
    It outputs. 16-DEC-12
  6. #4
  7. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by athar3432003
    It outputs. 16-DEC-12
    than that explains it

    if I do:
    PHP Code:
    <?php
    $V_CREATION_DATE 
    '16-Dec-12 11:44 AM';

    echo 
    date('d-M-y h:i:s',strtotime($V_CREATION_DATE));
    // outputs 16-Dec-12 11:44:00
    ?>
    Are you sure you are not altering the value you say you stored in the table?
    Last edited by aeternus; December 17th, 2012 at 02:26 AM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    14
    Rep Power
    0
    i am damn sure i am not altering the value
  10. #6
  11. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by athar3432003
    i am damn sure i am not altering the value
    Well somehow your value you claim exists in the table is being transformed to only show the date part.

    Does your query happen to include date() ?
    Could you otherwise show your query and the part where you assign
    $V_CREATION_DATE with the value from the database

    p.s. this might be useful
    Last edited by aeternus; December 17th, 2012 at 02:58 AM.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    14
    Rep Power
    0
    here i fetch
    Code:
    $V_CREATION_DATE = $row["CREATION_DATE"];
    here is the query.
    $query = "SELECT CREATION_DATE FROM ORACLE_TABLE";
    //parse the query
    $query_result = oci_parse($connect,$query);
    //execute the query
    oci_execute($query_result);
  14. #8
  15. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by athar3432003
    here i fetch
    Code:
    $V_CREATION_DATE = $row["CREATION_DATE"];
    here is the query.
    $query = "SELECT CREATION_DATE FROM ORACLE_TABLE";
    //parse the query
    $query_result = oci_parse($connect,$query);
    //execute the query
    oci_execute($query_result);
    Weird, I can't explain it than
  16. #9
  17. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,303
    Rep Power
    9400
    Somewhere between the database and $V_CREATION_DATE you're losing the time. We don't have your code so we can't see where, but you could...

IMN logo majestic logo threadwatch logo seochat tools logo