0

Hi there :)

I am doing a login log script and at first I didn't record the timestamp unlike all my newer logs, I was wondering is there a way to turn the date d/m/Y (15/02/2011) turned into a timestamp?

I would appreciate any help given
Thank you in advance!

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by diafol
0

If you're looking to replace the existing values with a timestamp, perhaps your best bet would be to create a new field called 'ts' (integer). Then create an update query that takes the value of your date field and transforms it into a timestamp and places it into ts. You can then delete the date field and rename the 'ts' field to whatever the date field was called - so that you don't break your php code and other queries.

"UPDATE table1 SET ts= UNIX_TIMESTAMP(STR_TO_DATE(datefield,'%d/%m/%Y'))"

I think that should work. If you want to try it, copy your table and try it on that, remembering to change the 'table1' in the sql to 'copy_of_table1' or to whatever you name it.

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.