Search Results

Search found 1503 results on 61 pages for 'timestamp'.

Page 4/61 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • sqlite3 timestamp (current_timestamp) one hour off

    - by Eiriks
    I run a small crawler on a virtual ubuntu server, initiated by crontab hourly. Datetime is inserted by defaulting the date filed to TIMESTAMP DEFAULT CURRENT_TIMESTAMP. Table creation looks like this: CREATE TABLE links (page TEXT, link TEXT, date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(page,link)); The datetime gets stored fine, but it one hour off (one hour behind) Norwegian time (GMT +1). The server is located where-ever, I just need it to be on GMT+1. By typing datein the ssh session I get: Wed Dec 19 17:26:02 CET 2012 and that is correct (just now). So where does sqlite3 get it's time from? What must I do to set the time so that sqlite3 gets the time right?

    Read the article

  • Converting timestamp to time ago in php e.g 1 day ago, 2 days ago...

    - by cosmicbdog
    hi everyone, i am trying to convert a timestamp of the format: 2009-09-12 20:57:19 and turn it into something like '3 minutes ago' with php. I found a useful script to do this, but I think its looking for a different format to be used as the time variable. The script I'm wanting to modify to work with this format is: function _ago($tm,$rcs = 0) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array('second','minute','hour','day','week','month','year','decade'); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]); if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); return $x; } I think on those first few lines its trying to do something that looks like this (different date format math): $dif = 1252809479 - 2009-09-12 20:57:19; How would I go about converting my timestamp into that (unix?) format?

    Read the article

  • Math with Timestamp

    - by Knut Vatsendvik
    table.sql { border-width: 1px; border-spacing: 2px; border-style: dashed; border-color: #0023ff; border-collapse: separate; background-color: white; } table.sql th { border-width: 1px; padding: 1px; border-style: none; border-color: gray; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } table.sql td { border-width: 1px; padding: 3px; border-style: none; border-color: gray; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } .sql-keyword { color: #0000cd; background-color: inherit; } .sql-result { color: #458b74; background-color: inherit; } Got this little SQL quiz from a colleague.  How to add or subtract exactly 1 second from a Timestamp?  Sounded simple enough at first blink, but was a bit trickier than expected. If the data type had been a Date, we knew that we could add or subtract days, minutes or seconds using + or – sysdate + 1 to add one day sysdate - (1 / 24) to subtract one hour sysdate + (1 / 86400) to add one second Would the same arithmetic work with Timestamp as with Date? Let’s test it out with the following query SELECT   systimestamp , systimestamp + (1 / 86400) FROM dual; ---------- 03.05.2010 22.11.50,240887 +02:00 03.05.2010 The first result line shows us the system time down to fractions of seconds. The second result line shows the result as Date (as used for date calculation) meaning now that the granularity is reduced down to a second.   By using the PL/SQL dump() function, we can confirm this with the following query SELECT   dump(systimestamp) , dump(systimestamp + (1 / 86400)) FROM dual; ---------- Typ=188 Len=20: 218,7,5,4,8,53,9,0,200,46,89,20,2,0,5,0,0,0,0,0 Typ=13 Len=8: 218,7,5,4,10,53,10,0 Where typ=13 is a runtime representation for Date. So how can we increase the precision to include fractions of second? After investigating it a bit, we found out that the interval data type INTERVAL DAY TO SECOND could be used with the result of addition or subtraction being a Timestamp. Let’s try again our first query again, now using the interval data type. SELECT systimestamp,    systimestamp + INTERVAL '0 00:00:01.0' DAY TO SECOND(1) FROM dual; ---------- 03.05.2010 22.58.32,723659000 +02:00 03.05.2010 22.58.33,723659000 +02:00 Yes, it worked! To finish the story, here is one example showing how to specify an interval of 2 days, 6 hours, 30 minutes, 4 seconds and 111 thousands of a second. INTERVAL ‘2 6:30:4.111’ DAY TO SECOND(3)

    Read the article

  • How to build a Django form which requires a delay to be re-submitted ?

    - by pierre-guillaume-degans
    Hey, In order to avoid spamming, I would like to add a waiting time to re-submit a form (i.e. the user should wait a few seconds to submit the form, except the first time that this form is submitted). To do that, I added a timestamp to my form (and a security_hash field containing the timestamp plus the settings.SECRET_KEY which ensures that the timestamp is not fiddled with). This look like: class MyForm(forms.Form): timestamp = forms.IntegerField(widget=forms.HiddenInput) security_hash = forms.CharField(min_length=40, max_length=40, widget=forms.HiddenInput) # + some other fields.. # + methods to build the hash and to clean the timestamp... # (it is based on django.contrib.comments.forms.CommentSecurityForm) def clean_timestamp(self): """Make sure the delay is over (5 seconds).""" ts = self.cleaned_data["timestamp"] if not time.time() - ts > 5: raise forms.ValidationError("Timestamp check failed") return ts # etc... This works fine. However there is still an issue: the timestamp is checked the first time the form is submitted by the user, and I need to avoid this. Any idea to fix it ? Thank you ! :-)

    Read the article

  • MySQL - Combine two fields to create a unix timestamp?

    - by Dan
    Hi, I'm trying to retrieve a UNIX timestamp from a query by combining a date and a time field in the table, however it keeps returning as zero. SELECT *, UNIX_TIMESTAMP(startdate starttime) AS start, UNIX_TIMESTAMP(enddate endtime) AS end FROM mytable; Can anyone help me out? Thanks.

    Read the article

  • Removing rows from MySQL table where the timestamp is over one day old?

    - by Rob
    I found the exact same question here. But it isn't working for me. I've modified it a bit, manipulated it, and I can't figure it out. I'm trying to remove rows that are over a day old. Here is my code: if (isset($_POST['prune'])) { $sql = "DELETE FROM logs WHERE time < date('now', '-1 days')"; mysql_query($sql); echo 'Logs older than one day removed.'; } Fairly simple question I suppose, but its bugging the hell out of me. I would appreciate any help. In case it makes a difference, the column is a TIMESTAMP type.

    Read the article

  • Oracle Database 12 c New Partition Maintenance Features by Gwen Lazenby

    - by hamsun
    One of my favourite new features in Oracle Database 12c is the ability to perform partition maintenance operations on multiple partitions. This means we can now add, drop, truncate and merge multiple partitions in one operation, and can split a single partition into more than two partitions also in just one command. This would certainly have made my life slightly easier had it been available when I administered a data warehouse at Oracle 9i. To demonstrate this new functionality and syntax, I am going to create two tables, ORDERS and ORDERS_ITEMS which have a parent-child relationship. ORDERS is to be partitioned using range partitioning on the ORDER_DATE column, and ORDER_ITEMS is going to partitioned using reference partitioning and its foreign key relationship with the ORDERS table. This form of partitioning was a new feature in 11g and means that any partition maintenance operations performed on the ORDERS table will also take place on the ORDER_ITEMS table as well. First create the ORDERS table - SQL CREATE TABLE orders ( order_id NUMBER(12), order_date TIMESTAMP, order_mode VARCHAR2(8), customer_id NUMBER(6), order_status NUMBER(2), order_total NUMBER(8,2), sales_rep_id NUMBER(6), promotion_id NUMBER(6), CONSTRAINT orders_pk PRIMARY KEY(order_id) ) PARTITION BY RANGE(order_date) (PARTITION Q1_2007 VALUES LESS THAN (TO_DATE('01-APR-2007','DD-MON-YYYY')), PARTITION Q2_2007 VALUES LESS THAN (TO_DATE('01-JUL-2007','DD-MON-YYYY')), PARTITION Q3_2007 VALUES LESS THAN (TO_DATE('01-OCT-2007','DD-MON-YYYY')), PARTITION Q4_2007 VALUES LESS THAN (TO_DATE('01-JAN-2008','DD-MON-YYYY')) ); Table created. Now the ORDER_ITEMS table SQL CREATE TABLE order_items ( order_id NUMBER(12) NOT NULL, line_item_id NUMBER(3) NOT NULL, product_id NUMBER(6) NOT NULL, unit_price NUMBER(8,2), quantity NUMBER(8), CONSTRAINT order_items_fk FOREIGN KEY(order_id) REFERENCES orders(order_id) on delete cascade) PARTITION BY REFERENCE(order_items_fk) tablespace example; Table created. Now look at DBA_TAB_PARTITIONS to get details of what partitions we have in the two tables – SQL select table_name,partition_name, partition_position position, high_value from dba_tab_partitions where table_owner='SH' and table_name like 'ORDER_%' order by partition_position, table_name; TABLE_NAME PARTITION_NAME POSITION HIGH_VALUE -------------- --------------- -------- ------------------------- ORDERS Q1_2007 1 TIMESTAMP' 2007-04-01 00:00:00' ORDER_ITEMS Q1_2007 1 ORDERS Q2_2007 2 TIMESTAMP' 2007-07-01 00:00:00' ORDER_ITEMS Q2_2007 2 ORDERS Q3_2007 3 TIMESTAMP' 2007-10-01 00:00:00' ORDER_ITEMS Q3_2007 3 ORDERS Q4_2007 4 TIMESTAMP' 2008-01-01 00:00:00' ORDER_ITEMS Q4_2007 4 Just as an aside it is also now possible in 12c to use interval partitioning on reference partitioned tables. In 11g it was not possible to combine these two new partitioning features. For our first example of the new 12cfunctionality, let us add all the partitions necessary for 2008 to the tables using one command. Notice that the partition specification part of the add command is identical in format to the partition specification part of the create command as shown above - SQL alter table orders add PARTITION Q1_2008 VALUES LESS THAN (TO_DATE('01-APR-2008','DD-MON-YYYY')), PARTITION Q2_2008 VALUES LESS THAN (TO_DATE('01-JUL-2008','DD-MON-YYYY')), PARTITION Q3_2008 VALUES LESS THAN (TO_DATE('01-OCT-2008','DD-MON-YYYY')), PARTITION Q4_2008 VALUES LESS THAN (TO_DATE('01-JAN-2009','DD-MON-YYYY')); Table altered. Now look at DBA_TAB_PARTITIONS and we can see that the 4 new partitions have been added to both tables – SQL select table_name,partition_name, partition_position position, high_value from dba_tab_partitions where table_owner='SH' and table_name like 'ORDER_%' order by partition_position, table_name; TABLE_NAME PARTITION_NAME POSITION HIGH_VALUE -------------- --------------- -------- ------------------------- ORDERS Q1_2007 1 TIMESTAMP' 2007-04-01 00:00:00' ORDER_ITEMS Q1_2007 1 ORDERS Q2_2007 2 TIMESTAMP' 2007-07-01 00:00:00' ORDER_ITEMS Q2_2007 2 ORDERS Q3_2007 3 TIMESTAMP' 2007-10-01 00:00:00' ORDER_ITEMS Q3_2007 3 ORDERS Q4_2007 4 TIMESTAMP' 2008-01-01 00:00:00' ORDER_ITEMS Q4_2007 4 ORDERS Q1_2008 5 TIMESTAMP' 2008-04-01 00:00:00' ORDER_ITEMS Q1_2008 5 ORDERS Q2_2008 6 TIMESTAMP' 2008-07-01 00:00:00' ORDER_ITEM Q2_2008 6 ORDERS Q3_2008 7 TIMESTAMP' 2008-10-01 00:00:00' ORDER_ITEMS Q3_2008 7 ORDERS Q4_2008 8 TIMESTAMP' 2009-01-01 00:00:00' ORDER_ITEMS Q4_2008 8 Next, we can drop or truncate multiple partitions by giving a comma separated list in the alter table command. Note the use of the plural ‘partitions’ in the command as opposed to the singular ‘partition’ prior to 12c– SQL alter table orders drop partitions Q3_2008,Q2_2008,Q1_2008; Table altered. Now look at DBA_TAB_PARTITIONS and we can see that the 3 partitions have been dropped in both the two tables – TABLE_NAME PARTITION_NAME POSITION HIGH_VALUE -------------- --------------- -------- ------------------------- ORDERS Q1_2007 1 TIMESTAMP' 2007-04-01 00:00:00' ORDER_ITEMS Q1_2007 1 ORDERS Q2_2007 2 TIMESTAMP' 2007-07-01 00:00:00' ORDER_ITEMS Q2_2007 2 ORDERS Q3_2007 3 TIMESTAMP' 2007-10-01 00:00:00' ORDER_ITEMS Q3_2007 3 ORDERS Q4_2007 4 TIMESTAMP' 2008-01-01 00:00:00' ORDER_ITEMS Q4_2007 4 ORDERS Q4_2008 5 TIMESTAMP' 2009-01-01 00:00:00' ORDER_ITEMS Q4_2008 5 Now let us merge all the 2007 partitions together to form one single partition – SQL alter table orders merge partitions Q1_2005, Q2_2005, Q3_2005, Q4_2005 into partition Y_2007; Table altered. TABLE_NAME PARTITION_NAME POSITION HIGH_VALUE -------------- --------------- -------- ------------------------- ORDERS Y_2007 1 TIMESTAMP' 2008-01-01 00:00:00' ORDER_ITEMS Y_2007 1 ORDERS Q4_2008 2 TIMESTAMP' 2009-01-01 00:00:00' ORDER_ITEMS Q4_2008 2 Splitting partitions is a slightly more involved. In the case of range partitioning one of the new partitions must have no high value defined, and in list partitioning one of the new partitions must have no list of values defined. I call these partitions the ‘everything else’ partitions, and will contain any rows contained in the original partition that are not contained in the any of the other new partitions. For example, let us split the Y_2007 partition back into 4 quarterly partitions – SQL alter table orders split partition Y_2007 into (PARTITION Q1_2007 VALUES LESS THAN (TO_DATE('01-APR-2007','DD-MON-YYYY')), PARTITION Q2_2007 VALUES LESS THAN (TO_DATE('01-JUL-2007','DD-MON-YYYY')), PARTITION Q3_2007 VALUES LESS THAN (TO_DATE('01-OCT-2007','DD-MON-YYYY')), PARTITION Q4_2007); Now look at DBA_TAB_PARTITIONS to get details of the new partitions – TABLE_NAME PARTITION_NAME POSITION HIGH_VALUE -------------- --------------- -------- ------------------------- ORDERS Q1_2007 1 TIMESTAMP' 2007-04-01 00:00:00' ORDER_ITEMS Q1_2007 1 ORDERS Q2_2007 2 TIMESTAMP' 2007-07-01 00:00:00' ORDER_ITEMS Q2_2007 2 ORDERS Q3_2007 3 TIMESTAMP' 2007-10-01 00:00:00' ORDER_ITEMS Q3_2007 3 ORDERS Q4_2007 4 TIMESTAMP' 2008-01-01 00:00:00' ORDER_ITEMS Q4_2007 4 ORDERS Q4_2008 5 TIMESTAMP' 2009-01-01 00:00:00' ORDER_ITEMS Q4_2008 5 Partition Q4_2007 has a high value equal to the high value of the original Y_2007 partition, and so has inherited its upper boundary from the partition that was split. As for a list partitioning example let look at the following another table, SALES_PAR_LIST, which has 2 partitions, Americas and Europe and a partitioning key of country_name. SQL select table_name,partition_name, high_value from dba_tab_partitions where table_owner='SH' and table_name = 'SALES_PAR_LIST'; TABLE_NAME PARTITION_NAME HIGH_VALUE -------------- --------------- ----------------------------- SALES_PAR_LIST AMERICAS 'Argentina', 'Canada', 'Peru', 'USA', 'Honduras', 'Brazil', 'Nicaragua' SALES_PAR_LIST EUROPE 'France', 'Spain', 'Ireland', 'Germany', 'Belgium', 'Portugal', 'Denmark' Now split the Americas partition into 3 partitions – SQL alter table sales_par_list split partition americas into (partition south_america values ('Argentina','Peru','Brazil'), partition north_america values('Canada','USA'), partition central_america); Table altered. Note that no list of values was given for the ‘Central America’ partition. However it should have inherited any values in the original ‘Americas’ partition that were not assigned to either the ‘North America’ or ‘South America’ partitions. We can confirm this by looking at the DBA_TAB_PARTITIONS view. SQL select table_name,partition_name, high_value from dba_tab_partitions where table_owner='SH' and table_name = 'SALES_PAR_LIST'; TABLE_NAME PARTITION_NAME HIGH_VALUE --------------- --------------- -------------------------------- SALES_PAR_LIST SOUTH_AMERICA 'Argentina', 'Peru', 'Brazil' SALES_PAR_LIST NORTH_AMERICA 'Canada', 'USA' SALES_PAR_LIST CENTRAL_AMERICA 'Honduras', 'Nicaragua' SALES_PAR_LIST EUROPE 'France', 'Spain', 'Ireland', 'Germany', 'Belgium', 'Portugal', 'Denmark' In conclusion, I hope that DBA’s whose work involves maintaining partitions will find the operations a bit more straight forward to carry out once they have upgraded to Oracle Database 12c. Gwen Lazenby is a Principal Training Consultant at Oracle. She is part of Oracle University's Core Technology delivery team based in the UK, teaching Database Administration and Linux courses. Her specialist topics include using Oracle Partitioning and Parallelism in Data Warehouse environments, as well as Oracle Spatial and RMAN.

    Read the article

  • why SET timestamp in Slow query logs?

    - by user79483
    I use mysql Ver 14.12 Distrib 5.0.86, for unknown-linux-gnu (x86_64) using readline 5.1, I am seeing below query in the slow query logs: # Time: 110907 7:00:09 # User@Host: XXX[XXX] @ [10.1.10.1] # Query_time: 3 Lock_time: 0 Rows_sent: 1 Rows_examined: 347519 SET timestamp=1315378809; # administrator command: Quit; # User@Host: XXX[XXX] @ [10.1.10.1] # Query_time: 3 Lock_time: 0 Rows_sent: 0 Rows_examined: 0 use XXX; SET timestamp=1315378809; # administrator command: Quit; # User@Host: XXX[XXX] @ [10.1.10.1] # Query_time: 3 Lock_time: 0 Rows_sent: 1 Rows_examined: 1 use XXX; SET timestamp=1315378809; # administrator command: Quit; It is on a master, with one slave attached. why SET timestamp in Slow query logs ? anyone can help me.

    Read the article

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

    - by Hermann
    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 application starts up and then just have StopWatch run and then just add the elapsed time from StopWatch to the initial value returned from DateTime.Now. At least that should give me accurate relative timestamps, right? What do you think about that (hack)? NOTE: StopWatch.ElapsedTicks is different from StopWatch.Elapsed.Ticks! I used the former assuming 1 tick = 100 ns, but in this case 1 tick = 1 / StopWatch.Frequency. So to get ticks equivalent to DateTime use StopWatch.Elapsed.Ticks. I just learned this the hard way. NOTE 2: Using the StopWatch approach, I noticed it gets out of sync with the real time. After about 10 hours, it was ahead by 5 seconds. So I guess one would have to resync it every X or so where X could be 1 hour, 30 min, 15 min, etc. I am not sure what the optimal timespan for resyncing would be since every resync will change the offset which can be up to 20 ms.

    Read the article

  • How to create a legally valid timestamp of unpublished game artwork

    - by mm24
    Before publishing promotional material of my first indie game I wanted to mark all my artwork with a legally valid timestamp. There are two ways I know to do this: 1 go to a sollecitor/lawyer and pay for them to certify the document 2 use an online webservice to mark any given file/folder readable to the service Anyone has already done this and if yes how (e.g. which website have you used? which type of solecitor have you contacted? etc..)? Kind Regards PS: I know that there is always the good old "send yourself a mail with a stamp and a date" but is not very strong as proof.

    Read the article

  • querying for timestamp field in django

    - by Hulk
    In my views i have the date in the following format s_date=20090106 and e_date=20100106 The model is defined as class Activity(models.Model): timestamp = models.DateTimeField(auto_now_add=True) how to query for the timestamp filed with the above info. Activity.objects.filter(timestamp>=s_date and timestamp<=e_date) Thanks.....

    Read the article

  • how to define current timestamp in yaml with doctrine

    - by Carson
    I tried the following yaml code: columns: created_time: type: timestamp notnull: true default: default CURRENT_TIMESTAMP In the outputted sql statement, the field is treated as datetime instead of timestamp, which I cannot define the current timestamp in it... If I insist to use timestamp to store current time, how to do so in yaml?

    Read the article

  • java program to get the current date without timestamp

    - by Lakshman
    I need a java program to get the current date without timestamp Date d = new Date(); gives me date and timestamp But i need only date, without timestamp. I use this date to compare with another date object that does not have timestamp. on printing System.out.println("Current Date : " + d) of d it should print May 11 2010 - 00:00:00 .

    Read the article

  • Sqlite: CURRENT_TIMESTAMP is in GMT, not the timezone of the machine

    - by BrianH
    I have a sqlite (v3) table with this column definition: "timestamp" DATETIME DEFAULT CURRENT_TIMESTAMP The server that this database lives on is in the CST time zone. When I insert into my table without including the timestamp column, sqlite automatically populates that field with the current timestamp in GMT, not CST. Is there a way to modify my insert statement to force the stored timestamp to be in CST? On the other hand, it is probably better to store it in GMT (in case the database gets moved to a different timezone, for example), so is there a way I can modify my select SQL to convert the stored timestamp to CST when I extract it from the table? Thanks in advance!

    Read the article

  • PreparedStatement and setTimestamp in oracle jdbc

    - by Roman
    Hi everyone, I am using PreparedStatement with Timestamp in where clause: PreparedStatement s=c.prepareStatement("select utctimestamp from t where utctimestamp>=? and utctimestamp<?"); s.setTimestamp(1, new Timestamp(1273017600000L)); //2010-05-05 00:00 GMT s.setTimestamp(2, new Timestamp(1273104000000L)); //2010-05-06 00:00 GMT The result I get is different, when I have different time zones on the client computer. Is this a bug in Oracle jdbc? or correct behavior? The parameter is Timestamp, and I expected that no time conversions will be done on the way. The database column type is DATE, but I also checked it with TIMESTAMP column type with the same results. Is there a way to achieve correct result? I cannot change default timezone in the the whole application to UTC. Thanks for your help

    Read the article

  • generate unix timestamp from last time

    - by Nazmin
    hi guys, suppose i have one column in mysql database which is stated last time one equipment is up in h:i:s format (ex: 00:05:11) or 1d21h, means that the equipment is on since 5 min before, what is the best method i can convert this to unix timestamp, say if using php script how? or direct convert last unix timestamp using mysql function query. actually, i want to calculate for start time for this equipment uptime in unix timestamp where i have one column in mysql startcapture that will be deducted with last column to get start time. so starttime = startcapture - last (this last time that has to convert to unix timestamp based on now() - h:i:s ). but the problem is sometimes the format change from h:i:s to ex: 1d22h, if h:i:s means the equipment is up since ex: 00:05:11 min before and if 1d22h means the equipment already up 1 day 22 hours before. so the main things here is to convert last column to appropriate unix timestamp. please help guys, asap.

    Read the article

  • git squash and preserve last commit's timestamp

    - by Crend King
    Consider I have commits ... -- A -- B -- C If I use git rebase -i to squash all three commits into one, we could pick A squash B squash C I see the resulted commit A has its original timestamp. How could make it inherit the timestamp of commit C (the last one)? What I can think of is git commit --amend --date=<new_time>, but I need to remember the timestamp of commit C before squash or from reflog. I find the timestamp of the latest timestamp is more reasonable, because it show when do I actually finish the work that are in the commits. Thanks.

    Read the article

  • How to Implement Dynamic Timestamp in Web Page?

    - by Morgan Cheng
    In Facebook and twitter, we can see that there is a timestamp like "23 seconds ago" or "1 hour ago" for each event & tweet. If we leave the page for some time, the timestamp changes accordingly. Since it is possible that user machine doesn't have same system time as server machine, how to make the dynamic timestamp accurate? My idea is: It is always based on server time. When request is sent to server for the web page, timestamp T1 (seconds to 1970/1/1) is rendered into inline javascript variable. The displayed timestamp ("23 seconds ago") is calculated by T1 instead of local time. I'm not sure whether this is how Facebook/Twitter do it. Is there any better idea?

    Read the article

  • Timestamp issue with localtime and mktime

    - by egiakoum1984
    Please see the code below: #include <iostream> #include <stdlib.h> #include <time.h> using namespace std; int main(void) { time_t current_time = 1270715952; cout << "Subscriber current timestamp:" << current_time << endl; tm* currentTm = localtime(&current_time); char tmp_str[256]; //2010-04-08T11:39:12 snprintf(tmp_str, sizeof(tmp_str), "%04d%02d%02d%02d%02d%02d.000", currentTm->tm_year+1900, currentTm->tm_mon+1, currentTm->tm_mday, currentTm->tm_hour, currentTm->tm_min, currentTm->tm_sec); cout << "Subscriber current date:" << tmp_str << endl; tm tmpDateScheduleFrom, tmpDateScheduleTo; memset(&tmpDateScheduleFrom, 0, sizeof(tm)); memset(&tmpDateScheduleTo, 0, sizeof(tm)); //2010-04-08T11:00 tmpDateScheduleFrom.tm_sec = 0; tmpDateScheduleFrom.tm_min = 0; tmpDateScheduleFrom.tm_hour = 11; tmpDateScheduleFrom.tm_mday = 8; tmpDateScheduleFrom.tm_mon = 3; tmpDateScheduleFrom.tm_year = 110; //2010-04-08T12:00 tmpDateScheduleTo.tm_sec = 0; tmpDateScheduleTo.tm_min = 0; tmpDateScheduleTo.tm_hour = 12; tmpDateScheduleTo.tm_mday = 8; tmpDateScheduleTo.tm_mon = 3; tmpDateScheduleTo.tm_year = 110; time_t localFrom = mktime(&tmpDateScheduleFrom); time_t localTo = mktime(&tmpDateScheduleTo); cout << "Subscriber current timestamp:" << current_time << endl; cout << "Subscriber localFrom:" << localFrom << endl; cout << "Subscriber localTo:" << localTo << endl; return 0; } The results are the following: Subscriber current timestamp:1270715952 Subscriber current date:20100408113912.000 Subscriber current timestamp:1270715952 Subscriber localFrom:1270717200 Subscriber localTo:1270720800 Why the current subscriber timestamp (subscriber date and time: 2010-04-08T11:39:12) is not between the range localFrom (timestamp of date/time: 2010-04-08T11:00:00) and LocalTo (timestamp of date/time: 2010-04-08T12:00:00)?

    Read the article

  • Tagged: 5 things SQL Server should drop

    - by AaronBertrand
    I was tagged by Paul Randal ( blog | twitter ) last night in his latest blog post, entitled, " What 5 things should SQL Server get rid of? " His top 5 pretty much coincide with my top 5, so I'll have to dig a little deeper. In no particular order: Syntax inconsistencies This isn't really a specific thing that Microsoft should get rid of, but rather an attitude and overall approach to SQL Server's long-term development. Every time they add a feature or option to SQL Server, it seems to be implemented...(read more)

    Read the article

  • Ubuntu one changes 'Date modified' to time and date of sync

    - by Philippe
    I'm wondering why ubuntu one changes the date of the synced files. Instead of leaving the actual date and time of modification it updates the time and date to the sync time. So, e.g., if I change and save a file today at july 26 2 pm and I go home and sync my home-pc with u1 tomorrow at 10 the 'Date modified' of that file will reflect the syncdate which might be July 27, 10am. I don't like that behavior and I don't understand if this is a bug or if that is actually intended?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >