If gnu date isn't giving what you need (based on the assumptions of what the output in this situation should be in your case), then there some options available on the CPAN

% perl -MTime::ParseDate -E 'say scalar localtime parsedate "-1 month"'
Mon Apr 30 12:44:29 2012

https://metacpan.org/module/Time::ParseDate


% perl -MDateTime -E 'say scalar localtime DateTime->now()->set_day(1)->subtract( months => 1 )->epoch() + (DateTime->now()->epoch() - DateTime->now()->set_day(1)->epoch())'
Tue May  1 12:44:34 2012

https://metacpan.org/module/DateTime

On 5/31/12 9:22 AM, Frank Bulk wrote:
I noticed a daily script was giving out some incorrect output, and looking
at it more closely I saw that the date function assumes a 30-day month:

nagios:/# date
Thu May 31 09:22:02 CDT 2012
nagios:/#nagios:/# date -d '-1 month'
Tue May  1 09:19:54 CDT 2012
nagios:/#

Shouldn't the output be April 31st?

Frank



_______________________________________________
Tech mailing list
Tech@lists.lopsa.org
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
  http://lopsa.org/

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Tech mailing list
Tech@lists.lopsa.org
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to