The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Problem in data time conversion
Discuss Problem in data time conversion in the PHP Development forum on Dev Shed. Problem in data time conversion PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 16th, 2012, 11:30 PM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 14
Time spent in forums: 3 h 31 m 30 sec
Reputation 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
|

December 17th, 2012, 12:26 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
What does
PHP Code:
print_r($V_CREATION_DATE);
output?
|

December 17th, 2012, 12:32 AM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 14
Time spent in forums: 3 h 31 m 30 sec
Reputation Power: 0
|
|
|
It outputs. 16-DEC-12
|

December 17th, 2012, 12:44 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
Quote: | 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 01:26 AM.
|

December 17th, 2012, 01:37 AM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 14
Time spent in forums: 3 h 31 m 30 sec
Reputation Power: 0
|
|
|
i am damn sure i am not altering the value
|

December 17th, 2012, 01:49 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
Quote: | 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 01:58 AM.
|

December 17th, 2012, 01:57 AM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 14
Time spent in forums: 3 h 31 m 30 sec
Reputation 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);
|

December 17th, 2012, 02:01 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
Quote: | 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
|

December 17th, 2012, 12:19 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
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...
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|