<?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: convert human date to epoch in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748278#M833523</link>
    <description>Tim,&lt;BR /&gt;&lt;BR /&gt;The GNU date command supports output of epoch, which I find to be rather useful if you need to convert the current time/date stamp to epoch.  Of course this only helps if you're trying to convert the current time/date stamp, rather than a supplied human date -&amp;gt; epoch.&lt;BR /&gt;&lt;BR /&gt;You can download a precompiled version of GNU date here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;syntax:&lt;BR /&gt;&lt;BR /&gt;date +%s&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;-Mike</description>
    <pubDate>Wed, 19 Jun 2002 19:46:05 GMT</pubDate>
    <dc:creator>Mike Hassell</dc:creator>
    <dc:date>2002-06-19T19:46:05Z</dc:date>
    <item>
      <title>convert human date to epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748276#M833521</link>
      <description>I see an number of references in here of using C to convert a supplied argument from epoch to a human date but how about human date to epoch ?  Looks like the ctime source should do it but I just can't seem to get it ..  &lt;BR /&gt;&lt;BR /&gt;Below is the source for the epoch to human.  Could someone elaborate for the reverse ?&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;int main(argc, argv)&lt;BR /&gt;int argc;&lt;BR /&gt;char **argv;&lt;BR /&gt;{&lt;BR /&gt;time_t t=strtoul(argv[1], NULL, 0);&lt;BR /&gt;printf("%s", ctime(&amp;amp;t));&lt;BR /&gt;}&lt;BR /&gt;&lt;/STDLIB.H&gt;</description>
      <pubDate>Wed, 19 Jun 2002 18:52:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748276#M833521</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2002-06-19T18:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: convert human date to epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748277#M833522</link>
      <description>Hi Tim:&lt;BR /&gt;&lt;BR /&gt;The function you are looking for is 'mktime'.&lt;BR /&gt;&lt;BR /&gt;I've attached a small example program that first gets the current time, displays it's epoch seconds and Year,Month,Day,Hr,Min, and Second. It then adds 1 to to day and calls mktime to get a new epoch seconds 1 day (86400 seconds later).&lt;BR /&gt;&lt;BR /&gt;That should be good enough to get you started.&lt;BR /&gt;&lt;BR /&gt;By the way, the stuff is really easy to do in both directions in Perl.&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Jun 2002 19:17:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748277#M833522</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-19T19:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: convert human date to epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748278#M833523</link>
      <description>Tim,&lt;BR /&gt;&lt;BR /&gt;The GNU date command supports output of epoch, which I find to be rather useful if you need to convert the current time/date stamp to epoch.  Of course this only helps if you're trying to convert the current time/date stamp, rather than a supplied human date -&amp;gt; epoch.&lt;BR /&gt;&lt;BR /&gt;You can download a precompiled version of GNU date here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;syntax:&lt;BR /&gt;&lt;BR /&gt;date +%s&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;-Mike</description>
      <pubDate>Wed, 19 Jun 2002 19:46:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748278#M833523</guid>
      <dc:creator>Mike Hassell</dc:creator>
      <dc:date>2002-06-19T19:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: convert human date to epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748279#M833524</link>
      <description>Also, the perl option&lt;BR /&gt;&lt;BR /&gt;/usr/contrib/bin/perl -e "print time"&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Wed, 19 Jun 2002 20:02:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748279#M833524</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-06-19T20:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert human date to epoch</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748280#M833525</link>
      <description>Thanks again to all..  THe below seems to work the best.&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;/DATE&gt;&lt;/STDLIB.H&gt;&lt;/ERRNO.H&gt;&lt;/STRING.H&gt;&lt;/TIME.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 13 Aug 2002 16:07:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-human-date-to-epoch/m-p/2748280#M833525</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2002-08-13T16:07:22Z</dc:date>
    </item>
  </channel>
</rss>

