0

Hi friends...
I have a variable $datetime= 140811 060632.
Here 140811 represents date in ddmmyy format and 060632 represents time 06:06:32 and both are in string type.
I have a column name "DtTime" in MSSQL of type "Datetime" stamp.
Now when i try to insert my variable $datetime in above column of database it returns an "out of memory" error which means I think I have to convert my string to "datetime" stamp type first and then try to insert.
I don't know how I can convert string to datetime type so that it inserts in column of "datetime" stamp type.
Please help...
Thanks in advance.....

3
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by mschroeder
0

Try this:

<?php
$datetime= "140811 060632";
$dt = str_replace(' ','',$datetime);
$a = str_split($dt,2);
$b = $a[2] .'-'. $a[1] .'-'. $a[0] .' '. $a[3] .':'. $a[4] .':'. $a[5];
echo date('Y-m-d H:i:s', strtotime($b)); # 2011-08-14 06:06:32
?>

bye!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.