Jump to content

Recommended Posts

I am attempting to write a php code to do an internal on line survey.  We want to date stamp the answers to the survey questions and store them in Oracle.

I know how to get the system date using the date function in PHP, but I"m having trouble actually storing it in a date type field in Oracle

  • 1 month later...

There are two ways to do this. If you want to store the date from the database server, you would execute a query like this:

 

insert into table(field)values(sysdate)

 

If you want to store the date from the web server, you would do this:

 

$current_time = date("d M Y H:i:s");

$insert = OCIParse($DB, "insert into table(field)values(to_date(:value, 'dd Mon yyyy hh24:mi:ss'))");

ocibindbyname($insert, ":value", $current_time);

OCIExecute($insert);

OCIFreeStatement($insert);

 

 

 

Of course, if your database and your web server reside on the same machine, it doesn't matter which one you use. It only matters if they're on two different machines and the clocks are off.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.