<?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: assign yesterday's date in ksh in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700616#M659301</link>
    <description>A not-so-subtle way of saying scripts should be in Perl, not sh.&lt;BR /&gt;&lt;BR /&gt;In order to do this in shell, I think you can manipulate the TZ variable - just add the proper number of hours to your current timezone offset, like so:&lt;BR /&gt;&lt;BR /&gt;gbrhpq$ echo $TZ&lt;BR /&gt;EST5EDT&lt;BR /&gt;gbrhpq$ date&lt;BR /&gt;Wed Oct 20 18:02:19 EDT 2010&lt;BR /&gt;gbrhpq$ expr 5 + 18 + 1&lt;BR /&gt;24&lt;BR /&gt;gbrhpq$ TZ=EST24EDT&lt;BR /&gt;gbrhpq$ date&lt;BR /&gt;Tue Oct 19 23:08:09 EDT 2010&lt;BR /&gt;gbrhpq$&lt;BR /&gt;&lt;BR /&gt;It looks like the trick is adding just enough hours to the timezone offset to take you back to sometime after 23:00 (11:00pm) the day before. If you add more, it goes back to the current date and time:&lt;BR /&gt;&lt;BR /&gt;gbrhpq$ TZ=EST25EDT&lt;BR /&gt;gbrhpq$ date&lt;BR /&gt;Wed Oct 20 18:17:09 EDT 2010&lt;BR /&gt;gbrhpq$&lt;BR /&gt;&lt;BR /&gt;I'm not sure if this will work at 7:00pm in the same way, though. We'll see...</description>
    <pubDate>Wed, 20 Oct 2010 21:19:59 GMT</pubDate>
    <dc:creator>mvpel</dc:creator>
    <dc:date>2010-10-20T21:19:59Z</dc:date>
    <item>
      <title>assign yesterday's date in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700613#M659298</link>
      <description>I have a requirement to assign yesterday's date in to a var.This should be compatible with all the months from Jan to Dec.&lt;BR /&gt;&lt;BR /&gt;I am using ksh. whether there is any command</description>
      <pubDate>Mon, 18 Oct 2010 05:54:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700613#M659298</guid>
      <dc:creator>satheeshnp</dc:creator>
      <dc:date>2010-10-18T05:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: assign yesterday's date in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700614#M659299</link>
      <description>Below should be helpful, many examples:&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=9251" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=9251&lt;/A&gt;</description>
      <pubDate>Mon, 18 Oct 2010 06:06:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700614#M659299</guid>
      <dc:creator>Anshumali</dc:creator>
      <dc:date>2010-10-18T06:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: assign yesterday's date in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700615#M659300</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# YESTERDAY=$(perl -MPOSIX -le 'print strftime "%b %e",localtime(time-(60*60*24))')&lt;BR /&gt;&lt;BR /&gt;# echo "${YESTERDAY}"&lt;BR /&gt;Oct 17&lt;BR /&gt;&lt;BR /&gt;This will compute yesterday's date in your local timezone.&lt;BR /&gt;&lt;BR /&gt;The Perl POSIX module allows you to use the 'strftime()' function with the same formatting directives you find in its manpages [ 'strftime(3C)' ].  These directives are the same as you use with the 'date' command.   The '%e' specification yields the day of the month with space fill whereas the '%d' uses zero-fill.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 18 Oct 2010 12:04:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700615#M659300</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-10-18T12:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: assign yesterday's date in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700616#M659301</link>
      <description>A not-so-subtle way of saying scripts should be in Perl, not sh.&lt;BR /&gt;&lt;BR /&gt;In order to do this in shell, I think you can manipulate the TZ variable - just add the proper number of hours to your current timezone offset, like so:&lt;BR /&gt;&lt;BR /&gt;gbrhpq$ echo $TZ&lt;BR /&gt;EST5EDT&lt;BR /&gt;gbrhpq$ date&lt;BR /&gt;Wed Oct 20 18:02:19 EDT 2010&lt;BR /&gt;gbrhpq$ expr 5 + 18 + 1&lt;BR /&gt;24&lt;BR /&gt;gbrhpq$ TZ=EST24EDT&lt;BR /&gt;gbrhpq$ date&lt;BR /&gt;Tue Oct 19 23:08:09 EDT 2010&lt;BR /&gt;gbrhpq$&lt;BR /&gt;&lt;BR /&gt;It looks like the trick is adding just enough hours to the timezone offset to take you back to sometime after 23:00 (11:00pm) the day before. If you add more, it goes back to the current date and time:&lt;BR /&gt;&lt;BR /&gt;gbrhpq$ TZ=EST25EDT&lt;BR /&gt;gbrhpq$ date&lt;BR /&gt;Wed Oct 20 18:17:09 EDT 2010&lt;BR /&gt;gbrhpq$&lt;BR /&gt;&lt;BR /&gt;I'm not sure if this will work at 7:00pm in the same way, though. We'll see...</description>
      <pubDate>Wed, 20 Oct 2010 21:19:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700616#M659301</guid>
      <dc:creator>mvpel</dc:creator>
      <dc:date>2010-10-20T21:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: assign yesterday's date in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700617#M659302</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; A not-so-subtle way of saying scripts should be in Perl, not sh.&lt;BR /&gt;&lt;BR /&gt;There was no subtle message in what I wrote.  I wasn't invoking a holy war; rather I was pointing out a pitfall that isn't necessarily apparent at first blush.  &lt;BR /&gt;&lt;BR /&gt;&amp;gt; In order to do this in shell, I think you can manipulate the TZ variable&lt;BR /&gt;&lt;BR /&gt;Sure, fraught with peril.  Oddly, if you look at *my* response to this technique in the link that Anshumali posted in this thread, you will see *why* using the TZ variable is a slippery slope.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Oct 2010 22:16:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/assign-yesterday-s-date-in-ksh/m-p/4700617#M659302</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-10-20T22:16:56Z</dc:date>
    </item>
  </channel>
</rss>

