hueymoo Posted May 7, 2007 Share Posted May 7, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/50379-using-php-to-save-system-date-in-oracle-table/ Share on other sites More sharing options...
igor berger Posted May 7, 2007 Share Posted May 7, 2007 Will storing it as a Unix stamp help? Then you can just store it as a number, later read it and convert it to date. Quote Link to comment https://forums.phpfreaks.com/topic/50379-using-php-to-save-system-date-in-oracle-table/#findComment-247398 Share on other sites More sharing options...
hueymoo Posted May 7, 2007 Author Share Posted May 7, 2007 Sorry no, we have no unix here whatsoever and I want to use the resulting Oracle table in a report in another tool Quote Link to comment https://forums.phpfreaks.com/topic/50379-using-php-to-save-system-date-in-oracle-table/#findComment-247435 Share on other sites More sharing options...
igor berger Posted May 7, 2007 Share Posted May 7, 2007 You do not need a unix server. PHP will give you a date as a UNIX stamp number! You can use another PHP function to convert that number to a date format! Look up the date() www.php.net it will lead you to the unix date Quote Link to comment https://forums.phpfreaks.com/topic/50379-using-php-to-save-system-date-in-oracle-table/#findComment-247656 Share on other sites More sharing options...
Feenix566 Posted July 3, 2007 Share Posted July 3, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/50379-using-php-to-save-system-date-in-oracle-table/#findComment-288856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.