Conversion of Unix time to GMT

Does anyone know of a way in which I can turn a date in unix time (no. of seconds since 1st Jan 1970) into a standard GMT format?
Any help would be greatly appreciated.
Thanks!

To use GMT time, use TimeZone:
* UnixTime.java
* Created on February 16, 2006, 11:20 AM
* @author Charles Li
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
public class UnixTime {
    public static void main(String[] args) {
        GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
        long unixTime = 1234567890L; // unix time is second
        long ONE_SECOND = 1000L; // 1 second = 1000 millisecond
        gc.setTimeInMillis(unixTime*ONE_SECOND);
        // 2009/2/13
        System.out.println("Year: " + gc.get(Calendar.YEAR));
        System.out.println("Month: " + (gc.get(Calendar.MONTH)+1));
        System.out.println("Day: " + gc.get(Calendar.DAY_OF_MONTH));
}

Similar Messages

  • Unix time conversion

    hi
    i have unixtime format 1075329297.572 how do i store it in database.that is with what datatype.i tried to store unixtime using date, timestamp but it does not work.
    but with varchar2 it works. but ifi store with varchar2 i cant perform conversion functions.
    i want to convert unix time into yyyy-dd-mm hh-mm-ss format.
    help me out
    thanks in advance

    how to convert julian Date  to timestamp datatype in Oracle

  • Convert Epoch (UNIX) time to a readable timestamp

    Post Author: uberwolfe
    CA Forum: Formula
    I am pulling data from a MS SQL 2000 database (for you phone phreaks out there, I am going against the Cisco CallManager CDR database).  The datetime stamp is in there as UNIX time.  I need to convert and split this into two fields, a date field and a time field.  As I have inherited this and don't know a lot about Crystal Reports I am at a loss.  Currently the report I have (that a developer who is no longer with us wrote) has two formula's.  The formulas are as follows: Time:CTime ({vw_OCESelectionDetail.dateTimeConnect}/8640025569) Date:CDate ({vw_OCESelectionDetail.dateTimeConnect}/8640025569) When the time is returned, it looks to be in GMT.  What type of formula would I need to have to convert the time to the correct time within the timezone I am in.  Any help would be appreciated.  

    Post Author: uberwolfe
    CA Forum: Formula
    Gave me an error stating the year needed to be between 1 and 9999.  I modified it as such CTime (({vw_OCESelectionDetail.dateTimeConnect} - 21600) / 86400 + 25569)
    CDate (({vw_OCESelectionDetail.dateTimeConnect} - 21600) / 86400 + 25569)  Running it right now, but it takes a while.  Let's see what happens.  Will post in a bit. 

  • Convert unix time stamp to readable time with daylight saving

    Hello NG,
    I have a table that has a column containing time stamps in the unix time format (seconds since 1970). If I show these times to the user, they should be converted to some readable format. I'm using the following sql code as an example:
    select to_char(
    to_timestamp_tz(
    to_char(
    to_date('01011970','ddmmyyyy') + 1/24/60/60 * 1086508800,
    'YYYY-MM-DD HH24:MI:SS')||' Europe/Warsaw',
    'YYYY-MM-DD HH24:MI:SS TZR'),
    'YYYY-MM-DD HH24:MI:SS TZH:TZM')
    from dual;
    The output I get is the following:
    TO_CHAR(TO_TIMESTAMP_TZ(TO
    2004-06-06 08:00:00 +02:00
    The output is right, but the format I need is the following:
    2004-06-06 10:00:00
    How do I have to alter the statement to get the correct result (add the two hours of the timezone and dst to the time)?
    Any help is appreciated.
    Regards,
    Mario Freimann

    That's the strange thin ... this timezone doesn't exist.
    Running the query I get the error message
    ORA-01882: timezone-region not found
    The results of the statement
    select * from V$TIMEZONE_NAMES;
    for Europe are:
    TZNAME TZABBREV
    Europe/Dublin LMT
    Europe/Dublin DMT
    Europe/Dublin IST
    Europe/Dublin GMT
    Europe/Dublin BST
    Europe/Istanbul LMT
    Europe/Istanbul IMT
    Europe/Istanbul EET
    Europe/Istanbul EEST
    Europe/Istanbul TRST
    Europe/Istanbul TRT
    Europe/Lisbon LMT
    Europe/Lisbon WET
    Europe/Lisbon WEST
    Europe/Lisbon WEMT
    Europe/Lisbon CET
    Europe/Lisbon CEST
    Europe/London LMT
    Europe/London GMT
    Europe/London BST
    Europe/London BDST
    Europe/Moscow LMT
    Europe/Moscow MMT
    Europe/Moscow MST
    Europe/Moscow MDST
    Europe/Moscow S
    Europe/Moscow MSD
    Europe/Moscow MSK
    Europe/Moscow EET
    Europe/Moscow EEST
    Europe/Warsaw LMT
    Europe/Warsaw WMT
    Europe/Warsaw CET
    Europe/Warsaw CEST
    Europe/Warsaw EET
    Possibly something is not right with my installation (Oracle 9.2.0.1.0) ...

  • Unix Time Stamp to Date for display

    Post Author: merph
    CA Forum: Formula
    I need to convert a unix time stamp to a readable date for a report. Does anyone outthere have a good formula for this?
    Thanks
    Merph

    Post Author: V361
    CA Forum: Formula
    If you can pull a couple of unix epoch times from the database, then let's run these formulae against them and see if it brings up the correct date and time separately.  These formula are pulled from another post by UberWolfe.
    ctime(( - 18000) / 86400+25569)
    cdate(( - 18000) / 86400+25569)
    The 18000 is for to convert for timezones for example 18000 is for     -5 GMT.

  • 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

  • Convert unix datetime to GMT

    Hi,
    I am trying to convert unix date time to GMT time. Need help in doing so.
    Sample unix datetime: 1150142460
    Thanks,
    Karthik
    Message was edited by:
    rkar20

    The format that you want to see the date displayed in. And (key point here) don't forget to call the setTimeZone method of the SimpleDateFormat object to see the date formatted as if it were in GMT.

  • UNIX time to Oracle time

    Hallo,
    I am acquiring the data for my reports in a UNIX evironment using embedded SQL.
    Therefore I am searching for a function that converts the UNIX time to ORACLE time. Currently I am doing the conversion via a string representation but I would prefer a function that does it on a binary level.
    Thanks a lot - Ulrich

    maybe (using the link provided) ;)
    select case when :unixts between -2114380800 and 2145916799
                then TO_DATE('19700101000000','YYYYMMDDHH24MISS') + NUMTODSINTERVAL(:unixts,'SECOND')
           end the_date
      from dualRegards
    Etbin

  • [SOLVED] C/C++ beginner, unix time question

    Hi
    To learn C/C++ I'm trying to make a little space calculator.
    First I would like to calculate the julian date of a given date. Using the Unix time this should be fairly simple.
    (Ignoring calendar changes etc. for now.)
    This is what I did so far:
    // Setting the time manually
    struct tm str_time;
    time_t unix_time; // (time in seconds from 1. Jan 1970 00:00:00 GMT)
    str_time.tm_year = 1970 - 1900; // (years from 1900)
    str_time.tm_mon = 1 - 1; // (month starting at 0)
    str_time.tm_mday = 1;
    str_time.tm_hour = 00;
    str_time.tm_min = 00;
    str_time.tm_sec = 00;
    str_time.tm_isdst = 0;
    unix_time = mktime(&str_time);
    printf("Given time is: %s\n", ctime(&unix_time));
    printf("Unix time: %i s\n", unix_time);
    ctime returns the correct given date Jan 1 00:00:00 1970.
    But the unix_time is -3600.
    Why is there an error of 1h/Shouldn't the unix_time be 0 ?
    Is it wrong to initialize tm this very simple way ?
    Last edited by rebootl (2013-05-25 16:12:33)

    rebootl wrote:
    Thanks. Yes that's correct.
    Then I can correct it by simply doing:
    int unix_time_corr = unix_time+3600;
    However, mktime seems to be limited to 1900-?? or so... so eventually I'll have to find another solution for this...
    This is all a bit intransparent to me.
    For example when I use str_time.tm_year = 1300 - 1900; The year 1300.
    unix_time is 331760832, which is wrong. That's OK cause it's outside the range of mktime (1900-..).
    But then ctime returns: Fri Jan  1 12:00:00 1300, the correct year. How is this possible ?
    1st of all, time_t is 'long unsigned', so your second printf()'s output is faulty. You should always compile with at least '-Wall' to detect those errors.
    As to why ctime() is returning correct date. My 1st suggestion is to read the man pages carefully.
    tm members are "int"s. So, they can accept negative values. ctime(t) is is equivalent to asctime(localtime(t)).
    My guess is that localtime(t) internally casts t to a signed value. And then assigns correct values to tm members. If that's the case. Then what's passed to asctime() is correct.

  • Need to convert time to GMT or UNIVERSAL CO-ORDINATED TIME

    Hi,
        I need to convert a date and time to UNIVERSAL CO-ORDINATED TIME or GMT. Is there any function module to do the same. Please do let me know.
    TIA
    Gurpreet

    Hi,
    Here is the example program to conver the time to UTC
    DATA: time_stamp TYPE timestamp,
           dat TYPE d,
           tim TYPE t,
           tz   TYPE ttzz-tzone,
           dst (1) TYPE c.
    tz = 'UTC '.     " You need to maintain the ZONE
    time_stamp = 20030309033000.
    CONVERT TIME STAMP time_stamp TIME ZONE tz
            INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
    WRITE: /(10) dat, (8) tim, dst.
    time_stamp = 20030309043000.
    CONVERT TIME STAMP time_stamp TIME ZONE tz
            INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
    WRITE: /(10) dat, (8) tim, dst.
    Regards
    Sudheer

  • How to convert a numeric field representing UNIX time to a standard report

    Looking for some help on the creation of a formula that will allow me to convert a numeric string which represent Unix time to a standard date format.
    Sample string value "1199149200", Jan 1 2008, 1 AM

    Hi,
    Use the DateAdd formula convert Unix epoch to normal datetime (Unix epoch = number of seconds that have elapsed since January 1, 1970).
    DateAdd("s", 1199149200, datetime("01/01/1970 00:00:00"))
    Cheers,
    Fritz

  • File Content Conversion in Unix AIX

    Hi all,
    the XI was migrate from Windows System to Unix AIX system. All process are running fine, but I have some file adapter with content conversion and Unix system are put the hexa char '0A' in the end/break of line and in the Windows System put the hexa char '0D 0A'. With this other system that process these files not work properly.
    How I to solve this problem? It is a problem?
    thanks.

    I solved using endSeparator = '0x0D''nl'
    []s

  • How do get current date/time in GMT?

    Is there any way to get the current date and time in GMT (while my current locale is not GMT)?
    In Java I can do this:
    long currenttime = System.currentTimeMillis();
    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
    df.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    java.util.Date date = new java.util.Date();
    date.setTime(currenttime);But, there seems to be no way to do the equivalent in BPEL in SOA Suite.
    I did some research and I think I could appy the XPath 2.0 function adjust-dateTime-to-timezone() to the current time, but that function is not available.
    Using SOA SUite 11.1.13.0.
    THanks.

    have you tried changing the stylesheet version in the xsl to 2.0 and then try the function again ?
    by changing this version it was possible to use newer functions, which weren't available in the designer

  • Time required in Unix time stamp format

    Hello ,
    I am new to java as I have recently started working on it.
    My requirement is to get current system date in Unix format which is integer(32 bit value) .Is there any class in java which will allow me to do this operation.
    Regards
    Vijay

    System.currentTimeMillis() returns a long (64bit integer) containing the number of milliseconds since Jan 01 1970. The UNIX time format is the number of seconds since Jan 01 1970, so all you need to do is get the time using System.currentTimeMillis(), divide by 1000, and cast it to an int (32 bit integer).

  • Function Module To Change TIME from GMT to CST

    Hello All,
    Can anyone tell me if there is any Function Module to convert the TIME from GMT to CST?
    Regards

    Hi Sunil,
    use the following code.
    DATA :
      timestamp like TZONREF-TSTAMPS,
      time      like sy-uzeit,
      date      like sy-datum.
    The following function module is used to convert the
    time and date into GMT timestamp
    CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
      EXPORTING
        i_datlo           = sy-datum
        i_timlo           = sy-uzeit
        I_TZONE           = 'INDIA'
    IMPORTING
       E_TIMESTAMP       = timestamp.
    The following function module is used to convert the
    above obtained timestamp to PST timezone date and time.
    CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'
      EXPORTING
        i_timestamp       = timestamp
        I_TZONE           = 'CST'
    IMPORTING
        E_DATLO           = date
        E_TIMLO           = time.
    write :/ 'Date and Time at PST zone is ',date, time.
    Reward if helpful.
    Thanks,
    Naveen.

Maybe you are looking for