Welcome Guest, Not a member yet? Register   Sign In
how to convert values to timestamp type in codeigniter

hi can anyone tell me if i take input from user the year the month and the date then how can these values can be set into such formate 'Y-m-d H:iConfused' so that i can put these values in DB field with type timestamp



Combination of strtotime() and date().

I have written the following code

          echo $int_date = mysql_to_unix($year.$month.$date.$hour.$minute.$second);

and get the following result: 1378133405 what does it mean?

well, since you are using the mysql_to_unix() function, you look that up, then look up any terms you aren't familiar with.

Why did you decide to use the mysql_to_unix() function in this code?

just 'cuz you're new doesn't mean you aren't expected to do your homework before asking questions.

Quote:and get the following result: 1378133405 what does it mean?
That 10 digit number is a UNIX timestamp, which is how PHP refers to dates. In your case, it literally refers to a specific time that is 1378133405 seconds after January 1, 1970: url=http://www.unixtimestamp.com/]unixtimestamp.com[/url]

Dealing with dates can be a tricky business, and you will always need to remember that PHP's date functions rely on the UNIX timestamp, so you now have to learn about it and work with it. MySQL formats those same dates in the 'Y-m-d H:iConfused' format. You will need to convert back and forth between those two formats (and others) often. The links that others included above will help you with that.

In my experience, when you don't get the expected result with dates, it is almost always a format or conversion issue.

Theme © iAndrew 2016 - Forum software by © MyBB