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. Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/ 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 Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/#findComment-1011765 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 Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/#findComment-1011772 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()) Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/#findComment-1011774 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. Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/#findComment-1011775 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. Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/#findComment-1012091 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). Link to comment https://forums.phpfreaks.com/topic/191907-default-value-of-unix_timestamp/#findComment-1012311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.