Kryptix Posted February 12, 2010 Share Posted February 12, 2010 I use UNIX_TIMESTAMP() a lot, is there anyway I can use that as a default value? It's a INT(10) and if I put UNIX_TIMESTAMP() in it says it's invalid. Quote Link to comment Share on other sites More sharing options...
jskywalker Posted February 13, 2010 Share Posted February 13, 2010 can you give some more info on HOW you are trying to update a field with UNIX_TIMESTAMP() als please specify how you defined the table you are trying to update Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 13, 2010 Share Posted February 13, 2010 Use TIMESTAMP field instead and set default value to CURRENT_TIMESTAMP Quote Link to comment Share on other sites More sharing options...
jskywalker Posted February 13, 2010 Share Posted February 13, 2010 Use TIMESTAMP field instead and set default value to CURRENT_TIMESTAMP Than i would prefer NOW() Just because its shorter... And NOW() is the same as FROM_UNITIME(UNIX_TIMESTAMP()) Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 13, 2010 Share Posted February 13, 2010 Use TIMESTAMP field instead and set default value to CURRENT_TIMESTAMP Than i would prefer NOW() Just because its shorter... And NOW() is the same as FROM_UNITIME(UNIX_TIMESTAMP()) Except, as OP has already find out, you can't use function as a default value. Quote Link to comment Share on other sites More sharing options...
Kryptix Posted February 14, 2010 Author Share Posted February 14, 2010 Hm, this is confusing. Is MySQL's TIMESTAMP the same as TIME() in PHP and UNIX_TIMESTAMP() in MySQL? I have thousands of database entries and it would be a pain to switch. Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 14, 2010 Share Posted February 14, 2010 No it's not the same. TIMESTAMP columns return time in YYYYMMDDHHMMSS format. No it wouldn't be a pain. You need three, at most four queries to do it (and change your PHP code). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.