timestamp

Return local time from unix timestamp with timezone identifier in php

对着背影说爱祢 提交于 2019-12-29 01:47:51
问题 I have a dropdown box on a webpage that takes a timezone identifier as the value (however I can change it to save the GMT offset if that is a better choice). Currently a user would be saving something like "America/Denver" as his / her time zone. I need to convert a unix timestamp into the user's local time for display in another portion of the page. What is the best way to accomplish this? Would it be better to store the GMT offset in the database and use that for a time calculation? Can

How to convert LDAP timestamp to Unix timestamp

拟墨画扇 提交于 2019-12-28 13:21:52
问题 When I retrieve the LDAP attribute "pwdLastSet" of an Active Directory using PHP I get a value like 1.29265206716E+17. I know that this value represents the date "Tue Aug 17 2010 14:11:11 GMT+0200". How can I convert this value to a Unix timestamp in PHP? Thanks for any hints! 回答1: Please see here. Actually it boils down to converting the FILETIME timestamp into a UNIX timestamp: $fileTime = "130435290000000000"; $winSecs = (int)($fileTime / 10000000); // divide by 10 000 000 to get seconds

CURRENT_TIMESTAMP in milliseconds

折月煮酒 提交于 2019-12-28 09:00:44
问题 Is there any way to get milliseconds out of a timestamp in MySql or PostgreSql (or others just out of curiosity)? SELECT CURRENT_TIMESTAMP --> 2012-03-08 20:12:06.032572 Is there anything like this: SELECT CURRENT_MILLISEC --> 1331255526000 or the only alternative is to use the DATEDIFF from the era ? 回答1: To get the Unix timestamp in seconds in MySQL: select UNIX_TIMESTAMP(); Details: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp Not tested

CURRENT_TIMESTAMP in milliseconds

落爺英雄遲暮 提交于 2019-12-28 09:00:12
问题 Is there any way to get milliseconds out of a timestamp in MySql or PostgreSql (or others just out of curiosity)? SELECT CURRENT_TIMESTAMP --> 2012-03-08 20:12:06.032572 Is there anything like this: SELECT CURRENT_MILLISEC --> 1331255526000 or the only alternative is to use the DATEDIFF from the era ? 回答1: To get the Unix timestamp in seconds in MySQL: select UNIX_TIMESTAMP(); Details: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp Not tested

Best timestamp format for CSV/Excel?

强颜欢笑 提交于 2019-12-28 08:06:39
问题 I'm writing a CSV file. I need to write timestamps that are accurate at least to the second, and preferably to the millisecond. What's the best format for timestamps in a CSV file such that they can be parsed accurately and unambiguously by Excel with minimal user intervention? 回答1: For second accuracy, yyyy-MM-dd HH:mm:ss should do the trick. I believe Excel is not very good with fractions of a second (loses them when interacting with COM object IIRC). 回答2: The earlier suggestion to use

Oracle date compare broken because of DST

独自空忆成欢 提交于 2019-12-28 06:42:22
问题 We've been debugging an issue with a SQL query executed from an app server running Java via Hibernate. The error: [3/10/14 10:52:07:143 EDT] 0000a984 JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 1878, SQLState: 22008 [3/10/14 10:52:07:144 EDT] 0000a984 JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions ORA-01878: specified field not found in datetime or interval We've been able to narrow this down to the simple SQL below. select * from

Oracle date compare broken because of DST

半城伤御伤魂 提交于 2019-12-28 06:41:31
问题 We've been debugging an issue with a SQL query executed from an app server running Java via Hibernate. The error: [3/10/14 10:52:07:143 EDT] 0000a984 JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 1878, SQLState: 22008 [3/10/14 10:52:07:144 EDT] 0000a984 JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions ORA-01878: specified field not found in datetime or interval We've been able to narrow this down to the simple SQL below. select * from

Is there a way to avoid automatically updating Rails timestamp fields?

点点圈 提交于 2019-12-28 03:31:12
问题 If you have DB columns created_at and updated_at Rails will automatically set those values when you create and update a model object. Is there a way to save the model without touching those columns? I am bringing in some legacy data and I would like to set those values from the corresponding values in the (differently named) legacy data fields. I'm finding when I set them on the model and then save the model, Rails appears to override the incoming values. Of course I could just name the Rails

When is a timestamp (auto) updated?

那年仲夏 提交于 2019-12-28 03:30:14
问题 If I have a column in a table of type TIMESTAMP and has as default: CURRENT_TIMESTAMP does this column get updated to the current timestamp if I update the value of any other column in the the same row? It seems that it does not but I am not sure if this is what should happen. I can not understand what this means (from MySQL documentation): If the column is auto-updated, it is automatically updated to the current timestamp when the value of any other column in the row is changed from its

When is a timestamp (auto) updated?

陌路散爱 提交于 2019-12-28 03:30:09
问题 If I have a column in a table of type TIMESTAMP and has as default: CURRENT_TIMESTAMP does this column get updated to the current timestamp if I update the value of any other column in the the same row? It seems that it does not but I am not sure if this is what should happen. I can not understand what this means (from MySQL documentation): If the column is auto-updated, it is automatically updated to the current timestamp when the value of any other column in the row is changed from its