convert epoch using date command

date -d ‘<Unix epoch> <epoch date> sec’

e.g. date -d ’1970-01-01 988822888 sec’ would dated “Wed May 2 17:31:28 MYT 2001″

20080430 :

get a particular date in epoch, e.g. date -d ‘Apr 30 2008 00:00:00′ ‘+%s’

Related posts:

  1. Set time & date automatically in KDE For NTP use in KDE : - apt-get install ntpdate...
  2. Modify or Adjust File Date Time on Unix/Linux You have folders or files in your server last modified...
  3. Changing File’s Date and Time on Unix Systems Change Data and Time of a File At times, we...
  4. ls & rm with regular expression e.g. rm -rf backup-20070[8-9]-* would delete : backup-200708-morning backup-200708-evening backup-200709-night...
  5. How to dig SRV record after creating it in DNS dig <record type> <host.name> e.g dig SRV _someservice._port.hostname.domainame.com.my OR dig...
  6. split – but no destination parameter to specify first : cd /destination/directory second : split /source/directory/big-huge-file prefix-to-apply-onto-splited-files Voila...
  7. Apache logs … While troubleshooting apache webserver, it would be helpful to have...
  8. vim – search & replace was searching what is the escape sequence for tab &...
  9. useful unix command: xargs In our mailserver, we backup every incoming email and keep...
  10. Troubleshoot Firefox – safe mode   Today, visited a website with flash and some how...

3 Responses to “convert epoch using date command”

  1. Patric Says:

    why not use the following?
    date -d ‘@’

    e.g. date -d @1216024547
    Mon Jul 14 10:35:47 CEST 2008

  2. suresh Says:

    Hi,
    I trying to convert epoch seconds to D/M/Y H:M:S.s format. I am passing epoch seconds as an argument to perl file.
    Inside perl file, the code looks like this:

    my $epoch = $ARGV[0];
    open(OUT, “>c:/dateResultFile.txt”);
    my $str = “date -d ’1970-01-01 $epoch sec’” ;
    print OUT “$str\n”;
    close(OUT);

    when i executed this code, i am getting i am not getting the date as i expected.
    Please suggest me the solution.

  3. MB Says:

    $ date +%s -d”Jan 1, 1980 00:00:01″
    date: 0551-402 Invalid character in date/time specification.
    Usage: date [-u] [+"Field Descriptors"]

    System used is AIX…this doesn’t work

Leave a Reply