Welcome Guest, Not a member yet? Register   Sign In
Working with date
#1

[eluser]Michal1[/eluser]
Hello guys,

I have problem with working with date and time. Let say I have simple css and when I add new article I want to save the date when the current article was created. The question what is the best type of table in mysql and how should I save it?

my controller function for adding articles look something like this:

Quote:public function add_article()
{
$article = array(
'title'=>$this->input->post('title')

);

$this->site_model->insert_article($article);

redirect ('site');
}

So I should probably create another field in that array and do something like

Quote:$article = array(
'title'=>$this->input->post('title')
'date'=> something here?
);
#2

[eluser]skunkbad[/eluser]
I save my dates as epoch time in int(10), but other people are probably going to suggest MySQL's DATE datatype. I just like epoch time because it's ready to format using php's date function. I can easily query for a date range by converting dates to epoch and using greater than or less than. You're likely to get people responding with the benefits of DATE too.
#3

[eluser]Stefan Hueg[/eluser]
I do also save my dates as unix timestamps.




Theme © iAndrew 2016 - Forum software by © MyBB