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 8839783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:18:53+00:00 2026-06-14T10:18:53+00:00

I have a variable of $i which is seconds in a shell script, and

  • 0

I have a variable of $i which is seconds in a shell script, and I am trying to convert it to 24 HOUR HH:MM:SS. Is this possible in shell?

  • 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-14T10:18:54+00:00Added an answer on June 14, 2026 at 10:18 am

    Here’s a fun hacky way to do exactly what you are looking for =)

    date -u -d @${i} +"%T"
    

    Explanation:

    • The date utility allows you to specify a time, from string, in seconds since 1970-01-01 00:00:00 UTC, and output it in whatever format you specify.
    • The -u option is to display UTC time, so it doesn’t factor in timezone offsets (since start time from 1970 is in UTC)
    • The following parts are GNU date-specific (Linux):
      • The -d part tells date to accept the time information from string instead of using now
      • The @${i} part is how you tell date that $i is in seconds
    • The +"%T" is for formatting your output. From the man date page: %T time; same as %H:%M:%S. Since we only care about the HH:MM:SS part, this fits!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old shell script which needs to be moved to bash. This
i have variable $lang which convert string to the selected language but i am
I have a variable which I get from database I want to output this
I have a variable $newTime , which is time in seconds made by mktime()
I have this string variable call status which is updated by a serial port
I have a heartbeat interval which calls a function every few seconds. This function
I have variable which I populate from JSON formated data. Something like: var time=my_data[data.results[i].id].time;
I have a variable which has to allow only numbers , dashes and parenthesis,
I have a variable which is referenced a lot. It started out as an
I have a variable which contains the value 1234567 . I would like it

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.