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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:14:05+00:00 2026-05-15T07:14:05+00:00

I have a 24 hour time string (ie 16:30) and would like to add

  • 0

I have a 24 hour time string (ie 16:30) and would like to add x time blocks of 30 mins. For example if x = 4, then 16:30 + 4(30) = 18:30. Is there any easy way to do this with out exploding the string and doing if statements for mins/hours.. etc? Also this is on a php page would it be easier to do this in php then echo it to the javascript?

Thanks for the help!

  • 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-15T07:14:06+00:00Added an answer on May 15, 2026 at 7:14 am

    You could add to a timestamp and then format it to HH:MM

    var x = 1;
    var d = new Date(Date.parse("1/1/2010 16:30") + x * 30 * 60 * 1000);
    var newTime = d.getHours() + ":" + d.getMinutes();
    

    You’ll want to pad zero’s to the hours and minutes.

    You can do it in PHP pretty much the same way:

    $x = 1;
    $newTime = date('H:i', strtotime('1/1/2010 16:30') + $x * 30 * 60);
    

    The new time will already be formatted with leading zero’s.

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

Sidebar

Related Questions

In my code, I have this loop, which brings up various 2-hour time blocks.
I have a String for example 23:0 which is a hour format. I need
I have date and time in a string formatted like that one: 2011-03-21 13:26
I have an array of Strings like this: private String time[] = {8:00:00 AM,
i have a time dropdown that shows hour in one select, minutes in another
I have an android application that displays a toast every hour and then every
I would like to calculate the remaining minutes to the next half an hour
I have a string like: Today, 3:30pm - Group Meeting to discuss big idea
I have a string containing a local date/time and I need to convert it
I have time stamps as string format Sun Jul 10 17:47:55 EDT 2011 I

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.