Convert Unix timestamp to LabVIEW time

Hello
I need to convert a Unix timestamp comming froma dll to a LabVIEW time. Does anybody now some ready to use function for this?
Thanks
Solved!
Go to Solution.

DAckermann wrote:
Oh yes. That was easy.
Thank you very much!
Exceot that there is a small possible gotcha. If you enter 1/1/1970 in a LabVIEW timestamp control and convert this to a double to get the number of seconds you likely end up with an error of your local timezone offset.
Both the Unix and LabVIEW epoch are defined respective to GMT which for most practical purposes is the same as UTC. So you have to make sure to get the number of seconds for a timestamp that shows 1/1/1970 00:00 UTC to be right.
Spoiler (Highlight to read)
If you ended up with 2082844800 as offset then you got it right.
If you ended up with 2082844800 as offset then you got it right.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • Converting unix timestamp to date after Daylight Saving Time change

    Hello,
    in one of the products we use the internal scheduler stores dates (and times) in an Unix-like format, that is seconds since 1st of January 1970. We have used this SQL to extract the actual date:
    TO_CHAR(t.next_fire_time/(24*60*60*1000) +to_date('19700101020000','yyyymmddhh24miss'),'yyyymmddhh24miss')
    Everything worked fine until the time has changed this weekend from UTC+2 to UTC+1 (we are located in Eastern Europe). Since then the query above returns one hour later than it should.
    I.e. timestamp *1320067800000* is returned as *20111031153000* even thought correct is (and the actual time the event was scheduled) *31-OCT-11 02.30.16.000000 PM*
    I found queries like this on different forums and no one seems to worry much about the daylight savings. Is this a configuration issue in the DB or is it a bug in our code?
    I tried selecting the SESSIONTIMEZONE and DBTIMEZONE and both were +1.
    Any help appreciated.

    Your problem is hard-coded 2hour offset:
    to_date('19700101<font size=5 color=red>02</font>0000','yyyymmddhh24miss')You need to calculate current offset to adjust it to current DST situation:
    with sample_table as (
                          select date '1970-01-01' + 1320067800000 / 1000 / 3600 / 24 dt_utc from dual
    select  dt_utc,
            dt_utc +
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) / 24 dt_prague,
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) tz_offset
      from  sample_table
    DT_UTC              DT_PRAGUE            TZ_OFFSET
    2011-10-31 13:30:00 2011-10-31 14:30:00          1
    SQL> SY.

  • How to convert a timestamp to date/time in CDS View?

    Dear experts,
    I would like to convert a timestamp to a date and time within a CDS view.
    This is what I tried to do:
    Cast (Cast(<timestamp> as abap.dec(8,0)) as abap.dats) as <date>
    I also thought about first converting the timestamp into a plain numerical character, then using substring and then casting it to abap.dats. Then its giving me an error that says: "dec can't be converted into numc".
    The above written code also throws an error - "function not allowed/ no cast within a cast".
    It is quite nasty not being able to write a cast within a cast - how else am i supposed to achieve a date here?
    I am looking forward to have your answers!
    Thanks and BR
    Anja

    Hi Anja,
    what you try to do is currently not possible, a feature not available in CDS views.
    Yet it surely is a feature, ABAP developers would like to see on the feature request list .
    Cheers,
      Jasmin

  • Convert UNIX timestamp in a report in Report Builder

    Hi,
    I have a column with unix timestamp (i.e 1386782654 ).
    How can I make that conversion to a dateformat  like 2013-03-05 17:32 ?
    I have tried =DateAdd("s", Fields!timestamp.Value, "19700101 00:00:00:000") but it just gives me an error.
    Anyone knows how to get this right?

    I solved it myself,
    The correct expression is: =DateAdd("s", Fields!timestamp.Value,"1970-01-01 00:00:00")

  • Select entries between two dates by converting Unix timestamp in Oracle Dat

    Hi,
    I need to select the entries between two dates from an Oracle db. The Oracle db has a column with Unix timestamps. I use the following querry, but it doesnt seem to be working as desired.
    select count(*) from reporter_status where to_char(FIRSTOCCURRENCE, 'mm-dd-yy') between ('08-07-06') and ('08-08-06');
    FIRSTOCCURRENCE has the Unix timestamps.
    Could anyone help me out with this. Thank you for your help.

    Assuming that it is actually a UNIX timestamp, then it is the number of seconds since Jan 1, 1970, so you need something like:
    SELECT COUNT(*)
    FROM reporter_status
    WHERE TO_DATE('01-Jan-1970', 'dd-mon-yyyy') + (firstoccurrence/24/60/60)
                    BETWEEN TO_DATE('08-07-2006', 'mm-dd-yyyy') AND
                            TO_DATE('08-08-2006, 'mm-dd-yyyy');Did Y2K not teach us anything? Use 4 digit years.
    John

  • Convert Unix timestamp to Readable Date/time

    Hello.
    I'm reading a database with the time field expressed in Unix Time (number of seconds since 1/1/1970 00:00).
    Is there any fast way to convert it to "mm-dd-yyyy hh:mm:ss" ?
    Regards.

    Try something like this:
    DateFormat shortTime = DateFormat.getTimeInstance(DateFormat.LONG);
    String theTime = shortTime.format(new java.util.Date());
    DateFormat shortDate = DateFormat.getDateInstance(DateFormat.MEDIUM);
    String theDate = shortDate.format(new java.util.Date());
    System.out.println("The formatted date is: " + theDate + " and the formatted time is: " + theTime);Check out the static fields in the DateFormat class for the different formatting options.
    Hope that helps!
    - Sheepy

  • How to convert short timestamp to long time stamp.?

    Can anybody help on converting a short time stamp into long timestamp?
    Regards
    Nitin

    Hi,
    CONVERT: DATE p_date TIME p_time INTO TIMESTAMP l_timestamp TIME ZONE sy-zonlo.
    thanks\
    Mahesh

  • Converting timestamp from local time to UTC

    Is there a smooth way to convert a timestamp containing local time to UTC time?
    The statement:
    CONVERT TIME STAMP time_stamp TIME ZONE tz
    INTO [DATE dat] [TIME tim]
    [DAYLIGHT SAVING TIME dst].
    Consideres time_tamp to be UTC time and then tries to convert it to the time zone specified in tz. What I would like to have done is the opposite, to have time_stamp represent the local time and then convert it back to UTC.
    TIA!
    /Armin

    Hi Armin.
    Just turn your statement and you will be fine
    DATA: date TYPE sydatum VALUE '20070525',
          time TYPE syuzeit VALUE '173030',
          cet  TYPE tzonref-tzone VALUE 'CET',
          utc  TYPE tzonref-tzone VALUE 'UTC',
          tstp TYPE timestamp.
    CONVERT DATE date TIME time INTO TIME STAMP tstp TIME ZONE cet .
    The output will be 15:30:30 at 25th of May 2007.
    I used CET as example, just use the timezone your date is representing. The result is formatted as UTC.
    Actually if you only have the timestamp, for this solution you have to convert it into date/time first.
    Use
    CONVERT TIME STAMP tstp TIME ZONE utc INTO DATE date TIME time.
    to do so.
    Regards,
    Timo.

  • Unix timestamp in cfgrid

    Sometime ago I produced a php and SQL jobsite. Users apply
    for jobs and the date they apply is converted into a unix timestamp
    and inserted into the SQL as an integer.
    I am now using coldfusion increasingly more, and am wanting
    to display the results above using a cfgrid.
    Although I have found similar posts in this forum I still
    have two oustanding queries:
    1) How do I catch the date for each row before the cfgrid
    displays it
    2) How to convert unix timestamp using coldfusion

    chilliroom wrote:
    >
    quote:
    format it via the db is probably the cheapest.
    > I am still unsure how to catch the date for each row
    before the cfgrd grabs it.
    what db? does it have this functionality? for sql server
    something like should
    work (but again watch for overflow):
    SELECT
    dateAdd(second,yourUnixEpochOffsetDataColumn,'1-jan-1970') as
    aDate,....
    FROM yourTable
    > How can I extract this value to then feed into
    "yourUnixEpochOffsetData".
    if your db can't handle this, here's one way using cf (but
    the db is cheaper).
    do your normal cfquery then:
    - convert the unix epoch offsets to datetimes:
    unixEpoch=createDate(1970,1,1);
    newDates=arrayNew(1);
    for (i=1; i LTE yourRegularcfQuery.recordCount;i=i+1) {
    newDates
    =dateAdd("s",yourRegularcfQuery.yourUnixEpochOffsetDataColumn,unixEpoch);
    depending on your needs, you might also want to dateFormat
    the results of the
    dataAdd:
    newDates
    =dateFormat(dateAdd("s",yourRegularcfQuery.yourUnixEpochOffsetDataColumn,unixEpoch));
    - add a column to your cfquery & fill with those
    converted dates,
    queryAddColumn(yourRegularcfQuery,"aDate","date",newDates);

  • UNIX Timestamp

    Hello
    How do I convert UNIX timestamp to Oracle
    Thanks
    Sameer

    hi,
    Write a Shell script which will pass the date to the procedure as a Parameter.
    Example.
    dt=`date`
    echo $dt
    sqlplus /nolog < scott/tiger 2>/dev/null <!EOF
    begin
    convertDate('$dt');
    end;
    !EOFThe Procedure.
    Create Or replace function convertDate(dt in Varchar2) return Date
    As
    convertDt Date;
    Begin
    -- Assuming that the Dt is 'Mon 3 Sep 2001 14:00:45'
    select to_date(dt, 'Dy DD Mon YYYY hh24:MI:SS') into convertDt from dual;
    return convertDt;
    End;Since i dont have a Unix Mac u will have to tweak the Shell Script on the Redirection Symbols.
    Oracle Does not support Timezones ... If u need to Incorportae TZ then pls look into a Java Solutiion.
    Hope this helps.
    Regards,
    Ganesh R

  • VI to convert Unix time to standard time?

    hi,
    I am in need of a VI to convert Unix time to Standard time?
    eg: Unix time: 1268845177 in seconds
    Standard time: GMT: Wed, 17 Mar 2010 16:59:37 GMT
                            Your timezone(U.S):
    Wednesday, March 17, 2010 10:59:37 AM
    I have the calculation but not full formula.
    Unix time is in seconds from Jan 1,1970, 00:00:00 UTC, starting at 0 counting forward.
    When 1268845177/86400 = 14685 days.
    86400 = 60*60*24 seconds
    But how to convert the 14685 days and relate to the current date, how it should be done?
    Either the formula or a VI to convert Unix time to standard time will be a help.
    Regards,
    Arvinth

    Timestamps and the PC clock vs. time on the net are different and I'd say somewhat unrelated concepts.
    You are worried about accuracy of the current time.  Timestamps have nothing to do with current time, but are a way of identifying and particular moment in time.
    Yes, the PC clock gets its time from the net assuming the time server settings are all set properly.  Even the correction of the current PC time may not happen exactly when the leap second gets inserted.  It may be some time before the PC resynchronizes with the net time.  The PC doesn't know if the existence of when a leap second will occur.  And neither does the LabVIEW timestamp.
    Here is an example.  According to http://en.wikipedia.org/wiki/Leap_second, a leap second will occur at the end of June 30 of this year UTC.  Since my clock is eastern daylight time at that date, I put together an example for 8pm on June 30  (UTC +4).  You'll see that the 3 values (a second before, the exact time, and a second after) show they are all 1 second apart.  There is no extra second accounted for.  So in real life the time a second after  vs. a second before are actually 3 seconds apart, but LabVIEW only show 2 seconds.  Feel free to play with the attached snippet for different timezones and daylight savings time and all of that.
    I don't think you really have as big of a problem as you are trying to investigate here.  If your timing needs are that critical where you need accuracy of the current time to better than a second, then you shouldn't be looking at LabVIEW timestamps, PC time clock, or internet time at all, but look at a high accuracy timing source perhaps based on a GPS clock.
    Unless you have a particular test planned to run over the expected point of time where a leap second is inserted, then you shouldn't have to worry.  Even if you do have a test run over the leap second, you probably don't need to worry either.  If the test is based on a waveform datatype, then you have a T0 timestamp, and a dT that will keep track of all the individual data points accurately.
    Attachments:
    Example_VI.png ‏20 KB

  • Converting a Labview time into a string with Measurement Studio C++

    In my Measurement Studio-based C++ application, I'll be sent a Labview
    time in the format of a double, which I believe is seconds since 1904.
    Does Measurement Studio for Visual C++ contain a function that will
    convert that time value into a string format? I'd like to end up with
    something like "hh:mm:ss:msec". I'm basically looking for the
    equivalent of the Labview vi, "Format Time/Date String". If Measurement
    Studio doesn't provide this, is there some other (hopefully simple) way
    to do this?
    I can request that the Labview application send me time in a string
    format as well as a double; this will require several changes to the
    Labview application sending the timestamp, but if that is a simpler
    solution that's the option we'll take.
    Thanks in advance,
    Adam

    Measurement Studio does not have a function for this, but you can do
    this yourself by first converting from LV epoch (1/1/1904) to Unix
    epoch(1/1/1970) and then using c runtime time functions
    UNIXEpochOffset is the difference between the 2 epochs at GMT. To
    convert to a UNIX system clock value, just subtract the sum of this
    number and your time zone offset in seconds
    lvTime is the value returned by LV timestamp
    #define  UNIXEpochOffset 2082844800
    int _tmain(int argc, _TCHAR* argv[])
        __int64 lvTime = 3214396284; //10:48:13.173 AM 11/9/2005
        //GMT offset for Central Time is -6 (3600 seconds). You will need to account for daylight savings time.
        int offset = -3600;
        time_t unixTime = lvTime - UNIXEpochOffset - offset;  
        struct tm *newtime = localtime(&unixTime);
        printf(asctime( newtime )); //prints out the time in a string format.
        return 0;
    Bilal Durrani
    NI

  • How can i convert the firefox-history-timestamp in places.sqlite into a normal date format? The firefox-timestamp is not equivalent to the unix-timestamp, that's why I ask. I could not find a conversion function. Does anyone know something about this?

    As I opened the places.sqlite with an sqlite-editor I found out that firefox saves the last_visit_date via a timestamp which is 16 digits long. I realized that the first 10 digits are similar to the corresponding unix-timestamp but not equal. So.. how can i convert the firefox-timestamp into a normal date? Or into the corresponding unix-timestamp?

    Write a bash script or 'C' program to change the date format and then use the sql update function to receive the stdio output 'where date_field='embeded date value'.

  • Converting unix data to normal date time.

    Post Author: Keshavan
    CA Forum: Formula
    Hi,
    Can anyone help me out on how to convert the unix date time format to normal date time? I should convert this unix data to proper time format also with GMT+5:30 hrs. Please help me to do the same.
    Thanks in advance,
    Keshavan.

    Post Author: V361
    CA Forum: Formula
    Could you provide some samples, I am not sure what a Unix data time looks like.
    Unix date that displays:
    Date you want to display:

  • Unix timestamp conversion to human readable representation ...

    Hi,
    I map unix timestamps from MaxDB to the controller context of Web Dynpro and display the results in a table. Is there a smart way to convert the timestamps to human readable date and time? Maybe some way to manipulate the table values with a function before they are written ..?
    For now, I create a new node in the context and manually set each value with the according date/time representation ... but thats pretty cumbersome.
    Thank you very much for your help!
    Cheers,
    boris

    Hi Boris,
    Check http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
    Date currentTime_1 = new Date(longUnixTimestamp);
    String dateString = formatter.format(currentTime_1);
    I would suggest you to create a calculated attribute under the same node as initial timestamp value and return a result of SimpleDateFormat.format().
    Best regards, Maksim Rashchynski.

Maybe you are looking for

  • How can i scan multiple pages in a single file in pdf.

    How can i scan multiple pages in a single file in pdf using 1536 dnf.

  • Creation of sales order using IDOC

    Hello All, PO is created in a website,which comes to SAP as a Idoc.Sales order need to be created with this idoc information. We are extending ORDERS05, since we are in need to add z segment as a child segment of E1EDKA1 to hold 3 email addresses. Co

  • Why won't my RAW files import into LR4?

    Hello all, Something very strange is going on with LR4.  I have been using LR since version 1 and never had this happen before.  When I have an SD card filled with jpegs and RAW files from my Fuji X100 camera and try to import all of them into LR 4,

  • Itunes has stopped working when turning on genius for windows 7

    Has anyone had itunes has stopped working while trying to turn on genuis for windows 7.  Also i have a new toshiba satellite c655d-s5200 laptop. Thanks

  • ARCHIVING MM-EBAN

    Hi experts, We are in the process of archiving PR..We have some doubt in that.. We are in 4.70 enterprise... Our archiving cretiria is as follows. 1. We want to archive PRs upto date of 31.3.2006. We found in SARA MM-EBAN in selection variant there i