Command to convert from UnixTime to Normal

Many are the times that I find dates in Unix format, obviously I do not understand a demon of what date and time they are showing me, that is where it is necessary to convert that which is in UnixTime to "normal".

But, first the question:

What is Unix Time?

We can read to Wikipedia and we will see that the number in front of us is the number of seconds that have passed since January 1, 1970 until that moment, something like "1437905791" actually means: 2015-07-26 10:16:31

Where do I find dates in the Unix Time format?

Many applications tend to save dates or moments in this format in the database they use, forums, application servers, etc.

How to convert from UnixTime terminal to something you can understand?

Simple, suppose we have the following date: 1416483005

To convert it to something that we can understand, just put: date -d@

That is:

date -d @1416483005

And that will tell us what it represents on November 20, 2014, at 06:30:05

convert-unix-time

Is there a website to convert from UnixTime?

Yes of course, Google «date unix»And voila, they will see a lot of results.

Can I get the converted direct MySQL date?

Yes of course, assuming it is a database called stats, a table called teams, and have a field called date that is in Unix format, the query to get all the data from that converted field would already be:

select FROM_UNIXTIME(date) from stats.times;

That is, we have a function called FROM_UNIXTIME () that helps us for this conversion, if inside the parenthesis we put the field whose information is of that type, it converts it.

The end!

Well there is not much more to add, enjoy!


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   saeron said

    álaaaaa did not know that this format would be used, which is orthopedic, let's see what happens when the number reaches the maximum memory of the variable. The end of the world guys, everyone was wrong, in the end it will be unix who tells us when.

  2.   Mario Guillermo Zavala Silva said

    What an excellent publication… !! Thanks for the info !!!

    Cheers …

  3.   dhunter said

    The ccze log colorizer has an option to convert the unix date format.

    tailf /varlog/squid3/access.log | ccze -C

  4.   Armando Leisure said

    Very good post, it is quite useful to know the command, the unix time is a headache when you see a log and if you only see the number you have no idea what the date is in this format.

    1.    Azureus said

      Exactly, what the hell is asking you when the hell an event occurred in the system and not knowing how to translate that.

  5.   eliotime3000 said

    Good idea to display the time with Unixtime.

  6.   rain said

    I've been doing tests with time.h in c with time (0) it gives me the seconds since 1970, I know there are tools that do it automatically but I wanted to see it manually
    I add 1970 to the number of years that have passed since then, I obtain the years dividing the seconds by 60 to obtain minutes and again to obtain the hours then between 24 and I obtain the days for the last 365 and obtain the years.
    long year = 1970 + ((time (0) / 60/60/24/365)); gives me current date

    for the number of the month I take the current date and subtract the seconds from the date until last year, but I still have a seconds from last year.
    long numdelmes=time(0)-(((time(0)/60/60/24/365)-1)606024365);

    I take numdelmes and divide it by 60 to get the minutes and again by 60 to get the hours, the rest of a year. I already have the number of days this year now I take the remainder of the division between 7 and they give me the days
    long diasemana=((numdelmes/60/60/24)-365)%7;

    I repeat the process but I no longer divide by 7 but by 31 and I get the number of the month
    numdelmes=((numdelmes/60/60/24)-365)/31;

  7.   office said

    A great article, it has been totally clear, I also want to emphasize the work of the community, in the comments many doubts are also clarified and it is not easy to have people like this following a blog. A 10.