0

i have some data in my database mysql, which i receive with query in my model

$row = $this->fetchRow('id ='.$id);
return $row;

one of the column in my database table store date in timestamp format and i want to convert that with php function date in my model. how i can make that? how to get access to my data which now in $row?

socm_
  • 783
  • 11
  • 28
  • try to see the massive $row in controller (dont know how to see that in model) through print_r function, but if i try to do something with that - always get errors. now make that through view like echo date('d-m-Y',$this->escape($this->add_time)); but i think thats not right. with data from tables we must work in models, am i right? – socm_ Jul 29 '12 at 14:13

1 Answers1

0

I'm not sure exactly what you are asking, but if you are asking how to convert a datetime returned as the string YYYY-MM-DD HH:NN:SS, then these should help:

# PHP 5.3+:

$dt = new DateTime($row['timestamp']);
$time = $dt->getTimestamp();

# before PHP 5.3:

$time = strtotime($row['timestamp']);
Ross Smith II
  • 11,799
  • 1
  • 38
  • 43