hi guys,
I want to keep track of record modified in table
So in the end I have added 2 coloumns added_on and modified_on.
so now I want to set added_on and modified_on to same value initially and then whenever that record gets modified added_on should remain same but modified_on shud get updated. Please let me know how I can do that. Please tell me the appropriate data types and default values for those two coloumns as well.
Mysql timestamp
Started by Vikrant, Feb 11 2012 03:31 AM
2 replies to this topic
#1
Posted 11 February 2012 - 03:31 AM
#2
Posted 11 February 2012 - 05:09 AM
I personally do everything with mktime() PHP function.
That way I have a timestamp that I can easilly work with anywhere in my project.
If you do this the field setting would be int 11
Then the initial query set a var and just use the same var for both fields.
$now = mktime();
Then use that var $now for both added_on and modified_on
Letter just adjust the modified_on with a new mktime();
This is what I prefer.
Some people like MySQL functions &/or MySQL style date-time, some make their own functions for time.
There are a lot of ways to do it.
I just find the regular PHP mktime the easiest because its just a clean Unix timestamp and can be very easilly manipulated into any format later when displayed.
That way I have a timestamp that I can easilly work with anywhere in my project.
If you do this the field setting would be int 11
Then the initial query set a var and just use the same var for both fields.
$now = mktime();
Then use that var $now for both added_on and modified_on
Letter just adjust the modified_on with a new mktime();
This is what I prefer.
Some people like MySQL functions &/or MySQL style date-time, some make their own functions for time.
There are a lot of ways to do it.
I just find the regular PHP mktime the easiest because its just a clean Unix timestamp and can be very easilly manipulated into any format later when displayed.
#3
Posted 17 April 2012 - 11:02 PM
I make my MySQL a DATETIME field for date_added and date_modified.
I have a constant called DATETIME in PHP:
I have a constant called DATETIME in PHP:
<?php
define('DATETIME', date('Y-m-d H:i:s', strtotime('now'));
Simplicity is the ultimate sophistication. — Leonardo da Vinci












