timestamp

MySQL Timestamp - why all zeros?

和自甴很熟 提交于 2020-01-22 12:38:36
问题 I'm using PHPMyAdmin and I've got a MySQL table column called "timestamp." The type (surprise!) is TIMESTAMP , and in 'attributes' I've set it to ON UPDATE CURRENT_TIMESTAMP . However, each new record gets a timestamp that looks like this: 0000-00-00 00:00:00 I have explicitly set the default value to none, but when I save and come back to look, it is set to all zeros as above. The relevant PHP records page hits with this query: $query = "INSERT INTO `pagehit` (user_id, pageurl) VALUES ('" .

Extract the Day / Month / Year from a Timestamp on MYSQL

风格不统一 提交于 2020-01-22 07:34:05
问题 I have : $date = $actualite['date']; $actualite['date'] is a TIMESTAMP And I was wondering how can I extract from this timestamp the day, then the month, then the year in 3 variables. Thank you for your help :) 回答1: Use date_parse($actualite['date']); , which will return an array containing the day, month, year and other items. http://www.php.net/manual/en/function.date-parse.php Example: <?php print_r(date_parse("2006-12-12 10:00:00.5")); ?> Output: Array ( [year] => 2006 [month] => 12 [day]

Why does MySQL unix time stop short of the 32 bit unsigned integer limit?

半城伤御伤魂 提交于 2020-01-21 11:17:06
问题 mysql> SELECT FROM_UNIXTIME(2145916799), FROM_UNIXTIME(2145916800), POW(2,32-1)-1, 2145916799 - POW(2,32-1)-1; +---------------------------+---------------------------+---------------+----------------------------+ | FROM_UNIXTIME(2145916799) | FROM_UNIXTIME(2145916800) | POW(2,32-1)-1 | 2145916799 - POW(2,32-1)-1 | +---------------------------+---------------------------+---------------+----------------------------+ | 2037-12-31 18:59:59 | NULL | 2147483647 | -1566850 | +---------------------

Python List Group by Date

被刻印的时光 ゝ 提交于 2020-01-21 03:34:10
问题 Say I have a list looks like this: [(datetime.datetime(2013, 8, 8, 1, 20, 15), 2060), (datetime.datetime(2013, 8, 9, 1, 6, 14), 2055), (datetime.datetime(2013, 8, 9, 1, 21, 1), 2050), (datetime.datetime(2013, 8, 10, 1, 5, 49), 2050), (datetime.datetime(2013, 8, 10, 1, 19, 51), 2050), (datetime.datetime(2013, 8, 11, 2, 4, 53), 2050), (datetime.datetime(2013, 8, 12, 0, 29, 45), 2050), (datetime.datetime(2013, 8, 12, 0, 44, 13), 2050), (datetime.datetime(2013, 8, 13, 0, 34, 13), 2050), (datetime

How to get timestamp of tick precision in .NET / C#?

房东的猫 提交于 2020-01-18 03:57:05
问题 Up until now I used DateTime.Now for getting timestamps, but I noticed that if you print DateTime.Now in a loop you will see that it increments in descrete jumps of approx. 15 ms. But for certain scenarios in my application I need to get the most accurate timestamp possible, preferably with tick (=100 ns) precision. Any ideas? Update: Apparently, StopWatch / QueryPerformanceCounter is the way to go, but it can only be used to measure time, so I was thinking about calling DateTime.Now when the

Converting timezone for date faster using java

瘦欲@ 提交于 2020-01-17 05:19:13
问题 I have written this method for converting a date time zone. How do i reduce the execution time of this method further. public static Timestamp convertTimeZone(final Timestamp fromDate, final TimeZone fromTZ, final TimeZone toTZ ){ Long timeInDate = fromDate.getTime() ; int fromOffset = fromTZ.getOffset(timeInDate); int toOffset = toTZ.getOffset(timeInDate); Timestamp dateStamp = new Timestamp(fromDate.getTime()); if (fromOffset >= 0){ int diff = 0; if (toOffset > 0){ diff = (fromOffset -

How to show date once per day from an array with multiple timestamps

醉酒当歌 提交于 2020-01-16 18:34:15
问题 I have an array with multiple conversations and with every message that has been typed either by the user or by the admin a timestamp indicating at what time the message was sent. A conversation can end on the same day or it can continue the day after it was started or a week, month even a year later. I want to show the day (example: 7 MAY 2015) on the page indicating that the conversation is started today. And if the conversation is picked up on a later date i want to show that date of the

php convert a date to a timestamp

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 11:56:08
问题 I'm trying to convert 2 dates to timestamps. One is generated by php (today's date) and the other is input by the user $today = date("d-m-y"); // 01-12-13 $start_date = "28-11-13"; $todaytimestamp = strtotime($today); $starttimestamp = strtotime($start_date); echo "$today > $start_date <br>$todaytimestamp > $starttimestamp"; Problem is that the result are incorrect Result: 01-12-13 > 28-11-13 1008201600 > 1857686400 what's wrong ? 回答1: Always use four-digit years, as using two-digit years

Difference between two time resulting an error

こ雲淡風輕ζ 提交于 2020-01-15 11:18:26
问题 I have this situation, i want to calculate the late of an employee and to get the late, i need to Subtract time to get the minute/hour late of an employee. Suppose to be.. i have this code: $time = strtotime($time_in); $late_time = date("H:i", strtotime('+15 minutes', $time)); if(date("H:i:s",strtotime($time_duty[0]->time)) > $late_time ) { $time_difference = (date("H:i:s",strtotime($time_duty[0]->time)) - $late_time)/60; print_r($time_difference); } then i've encountered error Message: A non

Difference between two time resulting an error

自古美人都是妖i 提交于 2020-01-15 11:18:08
问题 I have this situation, i want to calculate the late of an employee and to get the late, i need to Subtract time to get the minute/hour late of an employee. Suppose to be.. i have this code: $time = strtotime($time_in); $late_time = date("H:i", strtotime('+15 minutes', $time)); if(date("H:i:s",strtotime($time_duty[0]->time)) > $late_time ) { $time_difference = (date("H:i:s",strtotime($time_duty[0]->time)) - $late_time)/60; print_r($time_difference); } then i've encountered error Message: A non