Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:52:26+00:00 2026-06-09T22:52:26+00:00

How to find the previous date for a given date as Aug 17 in

  • 0

How to find the previous date for a given date as Aug 17 in perl. I am able to get the current date in perl by using the below code. Can some-one help me to find the previous date for a given date.

Given date as : Aug 17
Required Date as : Aug 16
#Reverting the Date for the respective TimeZone
my $timezone='london';
my ($dt, $Curr_Bus_Date,$Curr_day);
$dt = DateTime->now(time_zone => $timezone);
$Curr_mon=$dt->strftime('%b');
$Curr_date=$dt->strftime('%d');
$Curr_date=~s/^0/ /;
$Curr_dt="$Curr_mon $Curr_date ";
print "The curr date is $Curr_dt \n";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:52:28+00:00Added an answer on June 9, 2026 at 10:52 pm

    The DateTime class has a subtract() method. It’s clearly documented.

    $ perl -MDateTime -E'say DateTime->now->subtract(days => 1)'
    2012-08-16T10:31:25
    

    You can also do it with Perl’s standard (since 5.10) Time::Piece and Time::Seconds classes.

    $ perl -MTime::Piece -MTime::Seconds -E'$t = localtime; $t -= ONE_DAY; say $t'Thu Aug 16 11:37:37 2012
    

    With both of those approaches you should bear in mind that subtracting one day from the current date won’t always get you to the previous day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to find previous date if current date is given as a String? Below
Possible Duplicate: In Perl, how can find the date of the previous Monday for
can I somehow (without using PHP) find nearest previous date of day in week?
How do I find the previous Monday's date, based off of the current date
How can I find out the date of last (previous) Friday or any other
How can I find the next day's date after a given date. For example,
We're developing a trading app where one can enter previous trades including date and
I need to Find Previous month name using Calender or any classes that in
I know this question is similar to several previous ones, but I can't find
I want to get the date of previous month in J2ME. I have found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.