Using a text box disply date and time.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yew12
    New Member
    • Mar 2008
    • 23

    Using a text box disply date and time.

    We are trying to get the following script to display the full date and time. The field we are calling does have both date and time in. Unfortunatly its only returning the date.

    So I tried putting the sql "to_date('Adate ','dd/mm/yyyy hh24:mi')" to disply the full field. No Luck

    Any help is much appresiated. Thanks.[php]<HTML>
    <HEAD><TITLE> Property Results </TITLE>
    </HEAD>
    <BODY>
    <?php
    $sql="Select * from Appointment where Appointment_id = ".$_GET["Appointment_id "];
    putenv("TNS_ADM IN=/u1/oracle/Products/shu10g/network/admin");
    $conn = OCILogon("Usern ame","Password" ,"shu10g");
    $stmt = ociparse($conn, $sql);
    ociexecute($stm t);
    ocifetchinto($s tmt,$row);
    ocifreestatemen t($stmt);
    ocilogoff($conn );
    ?>
    <form name="form1"met hod="post" action="appoint menthandler.php ">
    <input name="Appointme nt_id" type=hiddenid=" Appointment_id" value='<?php print $row[0];?>'>

    <table width="75%" border="1">
    <tr>
    <td><strong>App ointment ID</strong></td>
    <td><?php print $row[0];?></td>
    </tr>
    <tr>
    <td><strong><st rong>Staff ID
    </stong>
    </strong></td>
    <td><input name="Staff_id" type="text" id="Staff_id" value='<?php print $row[1];?>'></td>
    </tr>
    <tr>
    <td><strong><st rong>Tenant ID
    </string>
    </strong></td>
    <td><input name="Tenant_id " type="text" id="Tenant_id" value='<?php print $row[2];?>'></td>
    </tr>
    <tr>
    <td><strong>Pro perty ID</strong></td>
    <td><input name="Property_ id" type="text" id="Property_id " value='<?php print $row[3];?>'></td>
    </tr>
    <tr>
    <td><strong>Des cription</strong></td>
    <td><input name="Descripti on" type="text" id="Description " value='<?php print $row[4];?>'></td>
    </tr>
    <tr>
    <td><strong>App ointment Date</strong></td>
    <td><input name="Adate" type="text" id="Adate" value=
    '<?php
    $sql="Select to_date('Adate' ,'dd/mm/yyyy hh24:mi') from Appointment where Appointment_id = ".$_GET["Appointment_id "];
    putenv("TNS_ADM IN=/u1/oracle/Products/shu10g/network/admin");
    $conn = OCILogon("Usern ame","Password" ,"shu10g");
    $stmt = ociparse($conn, $sql);
    ociexecute($stm t);
    ocifetchinto($s tmt,$row);
    print $row[5];
    ocifreestatemen t($stmt);
    ocilogoff($conn );
    ?>'
    </td>
    </tr>
    <tr>
    <td><strong>Dur ation (Min)</strong></td>
    <td><input name="Duration_ Min" type="text" id="Duration_Mi n" value='<?php print $row[6];?>'></td>

    </tr>
    </table>
    <p>
    <input type="submit" name"Submit" value="Submit">
    </p>
    </form>
    </BODY>
    </HTML>[/php]
    Last edited by ronverdonk; Apr 11 '08, 05:53 PM. Reason: warning and code tags!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    warning:

    Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [code] tags in future.

    MODERATOR

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      I'm not really good with Oracle, so I can't tell if there is a problem with the SQL.

      But...You could always use the PHP date functions to format the date.

      Try getting the actual timestamp from your database and use the date function to create your output.

      If the database doesn't return a timestamp, try the strtotime function to convert it.

      Comment

      Working...