rbragg Posted September 6, 2007 Share Posted September 6, 2007 I have an Oracle db that has a column called DETAIL_DATE with a TIMESTAMP datatype. I have successfully stored current system times there. I am trying to format the date and time to my liking. I've read a bit about to_char() but I don't want to do the formatting inside of my query. Of course, the following gives me 06-SEP-07 10.38.30.000000 AM : <?php $detailDate = ociresult($callDetails,"DETAIL_DATE"); echo $detailDate; ?> How can I format the date after fetching it using Oracle/PHP functions? I have also tried echoing: <?php echo date("M j, y @ h:i a", strtotime($detailDate) ); ?> But 06-SEP-07 10.38.30.000000 AM incorrectly turns into Sep 6, 07 @ 12:00 am. I've also tried using strftime instead of strtotime. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 you had it backwards <?php echo date("j ,M,y @ h.i.s.u a", strtotime($detailDate) ); ?> Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 Thanks for your reply. Changing the case of "M" only changes the month from the name to the number. So, now I have 12 31, 69 @ 07:00 pm. Wait, I'm re-reading since you edited. Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 Ok, I don't want to rearrange my formatting. I would like to keep the "Mon day, year @ Hr:min" format instead of the format you have and the periods. I want to keep this: Sep 7, 2007 @ 10:38 am. However, I don't think the format has anything to do with why my date is not displaying correctly. No matter the formatting, I'm getting the wrong date and time. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 you just printing the date or saving it in a database? Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 But 06-SEP-07 10.38.30.000000 AM incorrectly turns into Sep 6, 07 @ 12:00 am. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 maybe this will help http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_dates.html Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 Thanks for the link. I have read this before coming to post. The The Dates and Times in PHP section would apply to me. Unfortunately, my method, like this method, is not working. :-X On an earlier page, I INSERTed sysdate as a TIMESTAMP. Now, I'm just trying to pull the stamp from the db and formatting it. Even ... <?php echo date("M j, y @ h:i a", $detailDate); ?> ... gives me Dec 31, 69 @ 07:00 pm from the timestamp 06-SEP-07 12.03.31.000000 PM. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 whats the full code? appearantly your just pasting the echo date Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 Like in my first post: <?php $detailDate = ociresult($callDetails,"DETAIL_DATE"); # retrieving from query where field = DETAIL_DATE echo date("M j, y @ h:i a", $detailDate); ?> The field in my db is a TIMESTAMP. I don't imagine you'd need my actual query. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 <?php $detailDate = oci_result($callDetails,"DETAIL_DATE"); # retrieving from query where field = DETAIL_DATE echo date("M j, y @ h:i a", $detailDate); ?> Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 ociresult is the same thing as oci_result. There are 20 other queries on other pages that correctly work with that syntax. oci_result is used in PHP 5. ociresult is used in PHP 4 & 5. I'm using 4. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 im still lost how is it formatted wrong? Quote Link to comment Share on other sites More sharing options...
rbragg Posted September 6, 2007 Author Share Posted September 6, 2007 I don't know! That's what I'm trying to find out. LOL! I get the same date each time I echo on the page. Two records that have different dates stored in the db both result in Dec 31, 69 @ 07:00 pm when I have this: <?php $detailDate = ociresult($callDetails,"DETAIL_DATE"); echo date("M j, y @ h:i a", $detailDate); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 it might be your SQL Query i dont see anything wrong calling ociresult Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 also read up on Aodb and orcacle time and datestamps and include Aodb.inc.php in your script. http://phplens.com/lens/adodb/docs-oracle.htm Quote Link to comment 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.