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

  • Home
  • SEARCH
  • 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 6093237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:32:13+00:00 2026-05-23T12:32:13+00:00

I have a date in this format: 27 JUN 2011 and I want to

  • 0

I have a date in this format: “27 JUN 2011” and I want to convert it to 20110627

Is it possible to do in bash?

  • 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-05-23T12:32:13+00:00Added an answer on May 23, 2026 at 12:32 pm
    #since this was yesterday
    date -dyesterday +%Y%m%d
    
    #more precise, and more recommended
    date -d'27 JUN 2011' +%Y%m%d
    
    #assuming this is similar to yesterdays `date` question from you 
    #http://stackoverflow.com/q/6497525/638649
    date -d'last-monday' +%Y%m%d
    
    #going on @seth's comment you could do this
    DATE="27 jun 2011"; date -d"$DATE" +%Y%m%d
    
    #or a method to read it from stdin
    read -p "  Get date >> " DATE; printf "  AS YYYYMMDD format >> %s"  `date
    -d"$DATE" +%Y%m%d`    
    
    #which then outputs the following:
    #Get date >> 27 june 2011   
    #AS YYYYMMDD format >> 20110627
    
    #if you really want to use awk
    echo "27 june 2011" | awk '{print "date -d\""$1FS$2FS$3"\" +%Y%m%d"}' | bash
    
    #note | bash just redirects awk's output to the shell to be executed
    #FS is field separator, in this case you can use $0 to print the line
    #But this is useful if you have more than one date on a line
    

    More on Dates

    note this only works on GNU date

    I have read that:

    Solaris version of date, which is unable
    to support -d can be resolve with
    replacing sunfreeware.com version of
    date

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

Sidebar

Related Questions

I have a date format like this 2011-07-29T08:18:39 I want to convert this date
Suppose I have date string like mydate = 24-Jun-2011; I want to convert it
I have this date time format in string 11:56:41, 11/22/2011. Here's what I want:
I have date in this format 2011-11-02 . From this date, how can we
I have a (date time) stored in database in this format 2011-10-12 02:01:24 when
I have date in this format 1999-05-31T13:20:00.000-05:00 I want to add some hours or
I have date in this format 1999-05-31T13:20:00.000-05:00 I want to add some hours or
I have date in this format: 2010-01-11. I want to display JAN-11. How can
I have a date in this format 2068-06-15 . I want to get the
I have a date in this format: 20101101120000 I need to convert it to

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.