| 
	
 | 
 Posted by Kimmo Laine on 12/05/06 09:04 
"Sonnich" <sonnich.jensen@elektrobit.com> wrote in message  
news:1165309352.222966.35270@16g2000cwy.googlegroups.com... 
> 
> Kimmo Laine wrote: 
>> "Sonnich" <sonnich.jensen@elektrobit.com> wrote in message 
>> news:1165307408.725039.279250@f1g2000cwa.googlegroups.com... 
>> > I'd like to read out a date from the a DB, but as time var. By default 
>> > I seem to get it as a string. 
>> > 
>> > E.g. 
>> > while(odbc_fetch_row($result)) 
>> > { 
>> > $tt= odbc_result($result,2); 
>> >  echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>"; 
>> 
>> 
>> What kind of a string it is? If it's just a regular Y-m-d string, then  
>> the 
>> easiest would be first converting it to unix timestamp and then passing  
>> that 
>> to date: 
>> date("d.m.Y", strtotime($tt)); 
>> 
>> strtotime parses the formatted date string and converts it to integer. 
> 
> Server default format, I guess.... 
> 2006-12-05 00:00:00 
 
Then strtotime is your friend. Just pass the timestring the server gives to  
strtotime and use the timestamp it returns. 
 
 
--  
"Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia  koodiksi" - lpk 
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis 
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)
 
  
Navigation:
[Reply to this message] 
 |