How do I create a unix timestamp in MySQL? I know the type is set to INT and value is NULL but I need it to populate with current time in the format like: 1343782742
-
3You really could have Googled thisJohn Conde– John Conde2013-01-23 14:22:15 +00:00Commented Jan 23, 2013 at 14:22
-
I thought code help was for code helpBarclayVision– BarclayVision2013-01-23 14:26:05 +00:00Commented Jan 23, 2013 at 14:26
-
1Sure, if you show an effort. We're not here to do your work for you, thoughJohn Conde– John Conde2013-01-23 14:26:45 +00:00Commented Jan 23, 2013 at 14:26
-
3clearly your not here to help anyone with negative post - sometimes when something is new to a person, they just need a little help... sorry to have bothered you.BarclayVision– BarclayVision2013-01-23 14:31:18 +00:00Commented Jan 23, 2013 at 14:31
Add a comment
|
1 Answer
8 Comments
Naftali
Why use
CURDATE() and not NOW()?BarclayVision
actually I want it to store it in the database in that format on record creation?
John Woo
@JeffB the one I showed you was
SELECT, you need to use INSERT, example, INSERT INTO tableName (colName) VALUES (UNIX_TIMESTAMP(NOW())) . you can add more columns and values if you want.BarclayVision
I think i'm asking my question wrong... I want the field within the database to auto pupulate with the current datetime when a record is inserted. I have a 'timestamp' field in th database, if i set the TYPE to DATETIME and DEFAULT to CURRENT_DATE that will work, but not in unix format.
BarclayVision
I need the value stored in the DB as an INT not DATETIME in that format, I have hundreds of pages reading from that format in other DB i'm moving to new, so I need to keep in same format, where all new records get created with that field auto populating in unix datetime format.
|