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

Similar Messages

  • 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 Safari History lastvisiteddate to date time

    I want to Convert Safari History lastvisiteddate to date time.

    Post Author: newcruser
    CA Forum: Crystal Reports
    Thanks
    This is easy...second group based on the second formula 'for each hour'.
    How you group by 15 minutes?.
    i want to group by every 15 minutes starting from 9 AM to 5 PM.
    First i need to create a time range and then use that time range to group?.  Or any other simple and best way to solve this?. Please help
    How to create time range from 9 AM to 5 PM?

  • 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

  • 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")

  • 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.

  • Timestamp to readable date

    hi,
    just a quickie.
    how do i take the Date getTime() timestamp number and produce a viewable date
    i assume i use SimpleDateFormat, but is there any examples of it of how to do what i want.
    so i have stored in a variable the timestamp (e.g. 120234344550) and i want to take that variable and output something like (12/12/03) for instance (those numbers dont correspond by the way).

    If you go to the search page and do a search of the Tutorials for SimpleDateFormat, you will come up with this list:
    http://search.java.sun.com/search/java/index.jsp?and=simpledateformat&phr=&qt=&not=&field=&since=&nh=10&col=javatutorials&rf=0&Search.x=28&Search.y=8
    Something on one of these should probably help
    __[url http://Hi.. anyone!]___

  • 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 Epoch Date Time to Date Time format

    I am trying to convert Epoch Date time in GMT to Human Readable Date time format in UTC. I used the one below but it returns just the date in GMT but how can get datetime in UTC ?
    select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + STARTIME / 86400,'DD.MM.YYYY HH24:Mi:ss') FROM HQ_AVAIL_DATA_RLE;
    I refered a couple of forums and applied everything, but still I wouldn't get the timestamp.
    Please note that i'm looking for datetime stamp, not just the date.
    Thanks in advance!
    Edited by: 830754 on Jan 27, 2011 11:18 AM
    Edited by: 830754 on Jan 27, 2011 11:19 AM

    Works for me. I see date and time (submitted 1000 for STARTTIME):
    select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + 1000 / 86400,'DD.MM.YYYY HH24:Mi:ss')
    from dual
    TO_CHAR(TO_DATE('01
    01.01.1970 06:16:40Or do you mean something else?

  • Unix timestamp / epoch conversion in IQ

    Hello,
    I searched the community as well as some other historical locations, but couldn't find any discussions on this.
    In several of the projects I am working with, there is a source datetime field that always comes in as a unix timestamp (i.e. seconds since the epoch). The question I regularly get is, can we load this into IQ and have it converted during load from the integer into an IQ datetime column.
    I have my own suggestions for how to solve this already, but rather than influence the creative (or resolute) mind, I thought I'd put it out to the community to see how you have/would solve this issue?
    Thoughts??
    Thank you,
    -Joe Love
    SAP Mobile Services and Consumer Insights

    None that I am aware of during the LOAD TABLE event.  You can always load it and post process the data, but that's gets ugly and requires you to carry an extra column in your table.  My typical approach is to have the data converted before loading into IQ.  If the data is being touched by a streaming engine, ETL tool, or replication, you can do it all inline with those tools and a little coding.  For 3rd party tools, I would have them change their code to generate readable date/time stamps.  That or pre-process the data with something like sed or awk.
    Mark

  • 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

  • Convert from epoch timestamp to human readable date

    Hi everybody,
         I want to retrieve a human readable date from an fpga target of a sbRIO9636 ,so what is the function which can convert an epoch timestamp to a human readable date ? 
    (Noting that i need to retrieve the second,minute,hour,day,month,year... from the fpga target of this device)
    Thanks

    I have a program which retrieve the current time of windows (with the Get Date/Time in Seconds and Seconds to Date/time functions) and calculate the julian day parameter by using the second,minute,hour,day,month and year wich are displayed on the elements of the Unbundle By Name function (connected in the output of Seconds to Date/time function).
    This program works within windows and real time but I can't run it in the chassis of the sbRIO (errors displayed that these functions above aren't supported in the current target)
    Can i use another method to solve this problem.
    (See the front panel of this program in the following attached file)
    Attachments:
    julian day.PNG ‏110 KB

  • 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'.

  • Convert date/time to Unix epoch

    I have thousands of date time stamps I would like to convert to Unix epoch ten-digit strings. That is, take some thing like:
    Dec 9, 2005 10:24 AM
    and convert to
    1234567890 (only in the correct unix epoch time)
    What formula can I use? I've found that this "=DATE(1970,1,1)+P2/86400" can convert a 10 string epoch time down to just a date correctly, but without time. But I need to go in the opposite direction, with the time included.
    Using Numbers 09 ver 2.0.5 (368)

    CP,
    An up-to-date Unix Time would be provided by:
    =DUR2SECONDS((NOW()-"1/1/1970"))
    A somewhat more robust form would be:
    =DUR2SECONDS(NOW()-DATE(1970,1,1))
    If the time to be converted is in Cell P2, the expression would be:
    =DUR2SECONDS(P2-DATE(1970,1,1))
    Jerry

Maybe you are looking for