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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:58:40+00:00 2026-06-12T22:58:40+00:00

I am required to store a time value in an integer in the format

  • 0

I am required to store a time value in an integer in the format of HHMMSS. this time value is incrementing every second (basically a custom clock). however, since integers are naturally 10 based, I must implement a large cumbersome logic that extracts each digits and checks for 60 seconds in a minutes, 60 minutes in an hour and 24 hours a day. I wonder if there is some clever ways to do it without a massive if/else if chunk.

  • 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-12T22:58:41+00:00Added an answer on June 12, 2026 at 10:58 pm

    You can use the modulus operator to pick out each of the components of a single seconds counter:

    int totalSeconds;
    ...
    int seconds = totalSeconds % 60;
    int minutes = (totalSeconds / 60) % 60;
    int hours = (totalSeconds / 3600);
    

    Then you can just increment a single seconds counter and extract each of the components.

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

Sidebar

Related Questions

Suppose I want to lock based on an integer id value. In this case,
When submitting an app to the iOS App Store, one is required to declare
Code required to append list (anotherList) to item (id -= l1) of second list
I have a this asp.net page which upon first time load: 1: Make a
I'm trying to run this Perl script but it is not running as required.
I need to store 150 different tiny integer values (range from 0 to 7)
Quite simply, I need to store time series data in a document. I have
This is something I have been struggling about for some time now. The thing
My application requires me to store sets of bits along with some accompanying metadata
I am working on a app which requires me to store some directions for

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.