<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting 'date' to Epoch in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673548#M916865</link>
    <description>Thanks, but that was my question on converting Epoch to a date/time.  Now what I need is the reverse, take any date-format and convert it to Epoch.</description>
    <pubDate>Thu, 28 Feb 2002 15:52:09 GMT</pubDate>
    <dc:creator>Joel Shank</dc:creator>
    <dc:date>2002-02-28T15:52:09Z</dc:date>
    <item>
      <title>Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673546#M916863</link>
      <description>Can anyone tell me how to convert a standard UNIX date to a timestamp (seconds from Epoch).&lt;BR /&gt;&lt;BR /&gt;I know I can use time() to get the current Epoch, but I want to compute Epoch for ANY entered date.&lt;BR /&gt;&lt;BR /&gt;Thanks for your assistance,&lt;BR /&gt;jls</description>
      <pubDate>Thu, 28 Feb 2002 15:19:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673546#M916863</guid>
      <dc:creator>Joel Shank</dc:creator>
      <dc:date>2002-02-28T15:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673547#M916864</link>
      <description>Check this..&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x3d9b03bbece8d5118ff40090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x3d9b03bbece8d5118ff40090279cd0f9,00.html&lt;/A&gt;</description>
      <pubDate>Thu, 28 Feb 2002 15:31:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673547#M916864</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-02-28T15:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673548#M916865</link>
      <description>Thanks, but that was my question on converting Epoch to a date/time.  Now what I need is the reverse, take any date-format and convert it to Epoch.</description>
      <pubDate>Thu, 28 Feb 2002 15:52:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673548#M916865</guid>
      <dc:creator>Joel Shank</dc:creator>
      <dc:date>2002-02-28T15:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673549#M916866</link>
      <description>Hi Joel,&lt;BR /&gt;&lt;BR /&gt;This is one way of doing it, using perl &amp;amp; local timezones:&lt;BR /&gt;&lt;BR /&gt;============================================&lt;BR /&gt;#!/opt/perl5/bin/perl&lt;BR /&gt;&lt;BR /&gt;use Time::Local;&lt;BR /&gt;my %months=qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11);&lt;BR /&gt;my %days=qw(Sun 0 Mon 1 Tue 2 Wed 3 Thu 4 Fri 5 Sat 6);&lt;BR /&gt;&lt;BR /&gt;my ($hour,$min,$sec)=split ':',$ARGV[3];&lt;BR /&gt;my $day=$days{$ARGV[0]};&lt;BR /&gt;my $month=$months{$ARGV[1]};&lt;BR /&gt;my $mday=$ARGV[2];&lt;BR /&gt;my $year=$ARGV[4]-1900;&lt;BR /&gt;&lt;BR /&gt;my $time=timelocal($sec,$min,$hour,$mday,$month,$year);&lt;BR /&gt;print "$time\n";&lt;BR /&gt;===========================================&lt;BR /&gt;&lt;BR /&gt;So, to run it, you'd use:&lt;BR /&gt;&lt;BR /&gt;./date2epoch.pl Thu Feb 28 16:09:55 2002&lt;BR /&gt;1014912595&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 28 Feb 2002 16:08:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673549#M916866</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-02-28T16:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673550#M916867</link>
      <description>Thank you Robin.&lt;BR /&gt;&lt;BR /&gt;That will work.  Do you know how I can do this in C?  I'd really like to make this more portable.&lt;BR /&gt;&lt;BR /&gt;jls</description>
      <pubDate>Thu, 28 Feb 2002 16:17:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673550#M916867</guid>
      <dc:creator>Joel Shank</dc:creator>
      <dc:date>2002-02-28T16:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673551#M916868</link>
      <description>Hi Joel,&lt;BR /&gt;&lt;BR /&gt;Here goes:&lt;BR /&gt;&lt;BR /&gt;====================================&lt;BR /&gt;/*&lt;BR /&gt;&lt;BR /&gt;Convert date to epoch time&lt;BR /&gt;&lt;BR /&gt;*/&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;#define FALSE 0&lt;BR /&gt;#define TRUE  1&lt;BR /&gt;&lt;BR /&gt;int main(argc,argv)&lt;BR /&gt;int argc;&lt;BR /&gt;char *argv[];&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;        struct  tm      *dateptr;&lt;BR /&gt;        time_t  date;&lt;BR /&gt;        int             do_exit=FALSE;&lt;BR /&gt;&lt;BR /&gt;        if (argc != 2) {&lt;BR /&gt;                fprintf(stderr, "Usage: %s &lt;DATE&gt;\n", argv[0]);&lt;BR /&gt;                exit(1);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;        /* Convert date */&lt;BR /&gt;        dateptr = getdate(argv[1]);&lt;BR /&gt;        if (getdate_err != 0) {&lt;BR /&gt;                fprintf(stderr, "%s: Could not interpret %s. Error = %d\n", argv[0], argv[1], getdate_err);&lt;BR /&gt;                exit(1);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        date = mktime(dateptr);&lt;BR /&gt;    if (date == -1) {&lt;BR /&gt;                fprintf(stderr, "Could not \"mktime\" for date, errno=%d\n", errno);&lt;BR /&gt;                exit(1);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        printf("%d\n", date);&lt;BR /&gt;&lt;BR /&gt;        exit(0);&lt;BR /&gt;}&lt;BR /&gt;========================================&lt;BR /&gt;&lt;BR /&gt;Now create a file containing "%c", say, /tmp/datemsk&lt;BR /&gt;&lt;BR /&gt;and then:&lt;BR /&gt;&lt;BR /&gt;export DATEMSK=/tmp/datemsk&lt;BR /&gt;&lt;BR /&gt;Compile your program, then run it:&lt;BR /&gt;&lt;BR /&gt;# ./a.out "`date "+%c"`"&lt;BR /&gt;1014914858&lt;BR /&gt;&lt;BR /&gt;the file contains the date format that you wish to use (man getdate).&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.&lt;/DATE&gt;&lt;/STDLIB.H&gt;&lt;/ERRNO.H&gt;&lt;/STRING.H&gt;&lt;/TIME.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 28 Feb 2002 16:44:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673551#M916868</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-02-28T16:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 'date' to Epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673552#M916869</link>
      <description>Robin:&lt;BR /&gt;&lt;BR /&gt;Thank you so much.  This is EXACTLY what I was looking for!&lt;BR /&gt;&lt;BR /&gt;jls</description>
      <pubDate>Thu, 28 Feb 2002 17:18:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-date-to-epoch/m-p/2673552#M916869</guid>
      <dc:creator>Joel Shank</dc:creator>
      <dc:date>2002-02-28T17:18:28Z</dc:date>
    </item>
  </channel>
</rss>

