Excel time format: 12/24 hour, custom, default

This tutorial explains the basics and beyond of the Excel time format.

Microsoft Excel has a handful of time features and knowing them in depth can save you a lot of time. To leverage powerful time functions, it helps to know how Excel stores times. In this article, you will find everything you need to know about formatting time in Excel:

Excel time format

If you have been following our Excel Date Format tutorial, you know that Microsoft Excel stores dates as sequential numbers beginning with January 1, 1900, which is stored as number 1. As time is a portion of a day, times are stored as decimal fractions.

In Excel's internal system:

  • 00:00:00 is stored as 0.0
  • 23:59:59 is stored as 0.99999
  • 06:00 AM is 0.25
  • 12:00 PM is 0.5

When both date and time are entered in a cell, the value is stored as a decimal number comprised of an integer representing the date and a decimal portion representing the time. For example, 1 June 2025 9:30 AM is stored as 45809.39583. Time formatting in Excel

How to get a decimal number representing time in Excel

To get a decimal number representing a certain time, carry out these steps:

  1. Select a cell containing the time.
  2. Press Ctrl + 1 to open the Format Cells dialog box.
  3. On the Number tab, select General under Category, and you will see the decimal in the Sample box.

Now, you can write down that number and click Cancel to close the window. Or, you can click the OK button and have the time replaced with a corresponding decimal number in the cell. Get a decimal number representing the time in Excel.

To keep both the original time and its decimal representation, enter a simple formula like =B3 (where B3 is the time value) in any empty cell, and set the General number format for that cell. Return a decimal number representing the time in a separate cell.

This is the fastest way to convert time to decimal in Excel. You can also use different formulas to convert time to hours, minutes or seconds.

How to format time in Excel

Microsoft Excel is smart enough to recognize a time value as you type it in a cell. For example, if you type 20:30, or 8:30 PM, or even 8:30 p, Excel will interpret this as a time and display either 20:30 or 8:30 PM, depending on your default time format.

To change an existing time formatting or apply some specific one, use the Format Cells dialog as described below.

  1. Select the cell(s) that you want to format.
  2. Press Ctrl + 1 to open the Format Cells dialog.
  3. On the Number tab, select Time from the Category list, and then choose the desired format from the Type list.
  4. Click OK to apply the selected format and close the dialog box. Apply or change the time format in Excel.

Custom time format in Excel

Though Microsoft Excel provides a number of predefined time formats, you may want to create your own one that fits best for a particular sheet. This can also be done using the Format Cells dialog box:

  1. Select the target cells.
  2. Press Ctrl + 1 to open the Format Cells dialog.
  3. Under Category, select Custom and type the desired format code in the Type box.
  4. Review the Sample value to check if it's formatted as expected.
  5. Click OK to save the changes.

For example, to format a date time value like 1-Jun-2025 9:30 AM, utilize this code: d-mmm-yyyy h:mm AM/PM. Create a custom time format in Excel.

The custom time format you've created will be in the Type list the next time you need it.

Tip. The easiest way to make a custom time format is to use one of the existing formats as a starting point. For this, click Time in the Category list, and select one of the predefined formats under Type. After that switch to Custom and make the changes to the format displayed in the Type box.

Excel time formatting codes

When creating a custom time format in your worksheets, you can use the following codes.

Code Description Displays as
h Hours without a leading zero 0-23
hh Hours with a leading zero 00-23
m Minutes without a leading zero 0-59
mm Minutes with a leading zero 00-59
s Seconds without a leading zero 0-59
ss Seconds with a leading zero 00-59
AM/PM Periods of the day
(if omitted, 24-hour time format is used)
AM or PM

12 hour time format in Excel

To set the 12 hour format for times in Excel, include AM/PM in the format code that you enter in the Format Cells dialog.

Format Displays as
h:mm:ss AM/PM 1:30:00 PM
h:mm AM/PM 1:30 PM

To change time to 12 hour format, you can also use the TEXT function with one of the codes listed above.

Assuming the original time value is in A3, the formula takes this form:

=TEXT(A3,"hh:mm:ss AM/PM") Change time to 12 hour format.

Note. The TIME function converts a time value into a text string. If you intend to calculate times at a later point, then set a custom 12-hour format using the Format Cells dialog.

24 hour time format in Excel

To apply the 24 hour time format, use any format code without AM/PM.

Format Displays as
h:mm:ss 13:30:00
h:mm 13:30

Once you've decided on the format code, apply a corresponding custom format to the original cell or supply the format code to the TEXT function to return a formatted time in another cell. Remember that in the latter case, the output will be a text string.

With the source time in A3, the formula goes as follows:

=TEXT(A3,"hh:mm:ss") Change time to 24 hour format.

Excel time format over 24 hours

When adding up times, the total may exceed 24 hours. To format times over 24 hours correctly, enclose the hour code in square brackets like [h].

Here are some examples of time formats over 24 hours:

Format Displays as Explanation
[h]:mm 41:30 41 hours and 30 minutes
[h]:mm:ss 41:30:10 41 hours, 30 minutes and 10 seconds
[h] "hours", mm "minutes", ss "seconds" 40 hours, 30 minutes, 10 seconds
d h:mm:ss 1 17:30:10 1 day, 17 hours, 30 minutes and 10 seconds
d "day" h:mm:ss 1 day 17:30:10
d "day," h "hours," m "minutes and" s "seconds" 1 day, 17 hours, 30 minutes and 10 seconds

For more information, please see how to show, add, subtract over 24 hours, 60 minutes, 60 seconds.

Excel date time format

To create custom formatting for date and time, use various combinations of time and date format codes.

The following table provides some examples of how your Excel date time formats may look like:

Format Displays as
d-mmm-yy h:mm:ss AM/PM 13-Jan-25 1:30:00 PM
mmmm dd, hh:mm AM/PM January 13, 01:30 PM
dddd, m/d/yy h:mm:ss Monday, 1/13/25 13:30:00
ddd, mmmm dd, yyyy hh:mm Mon, January 13, 2025 13:30

Excel time format without date

To format a date time value so that only time is visible in a cell, use only the time codes without the date codes. At that, you can use the international standard notation such as hh:mm:ss or your custom notation. Here are a few examples:

Format Displays as
h:mm:ss AM/PM 1:30:00 PM
hh:mm:ss AM/PM 01:30:00 PM
hh:mm:ss 13:30:00
hh-mm-ss 13-30-00
hh.mm.ss 13.30.00

How to format negative time values

The custom time formats discussed above work for positive values only. If the result of your calculations is a negative number formatted as time (e.g. when you subtract a bigger time from a smaller one), the result will be displayed as #####. If you want to format negative time values differently, the following options are available to you:

  • Display an empty cell for negative times. Type a semicolon at the end of the time format, for example [h]:mm;
  • Display an error message. Type a semicolon at the end of the time format, and then type a message in quotation marks, e.g. [h]:mm;"Negative time"

Generally speaking, a semicolon acts as a delimiter to separate positive values' format from negative values' formatting. For full details, please see Custom Excel number format.

If you want to display negative times as negative values, e.g. -10:30, the easiest way is to switch to Excel's 1904 date system. For this, click File > Options > Advanced, scroll down to When calculating this workbook section and check the Use 1904 date system box.

For more information, please see How to calculate and display negative times in Excel.

Excel default time format

When setting up a time format in the Format Cells dialog, you may have noticed that one of the formats begins with an asterisk (*). This is the default time format in your Excel. The default time format in Excel

To quickly apply the default Excel time format to the selected cell or a range of cells, go to the Home tab > Number group, and choose Time from the Number Format drop-down list. Apply the default time format in Excel

How to change the default time format

To change the default time format in Excel, this is what you need to do:

  1. Open the Control Panel and click Region. If your Control panel opens in Category view, then click Clock and Region > Change the date, time, or number format.
  2. In the Region dialog box, set the Short time and Long time formats you want. Change the default time format in Excel.

Now that you've got the hang of time formatting in Excel, it will be much easier for you to manipulate date and time values in your worksheets. I thank you for reading and hope to see you on our blog next week!

Practice workbook for download

Excel time formatting - examples (.xlsx file)

269 comments

  1. I have sum all my employee working house with =SUM(C2:C26), I got a total of 810:07 hours (format [h]:mm) When I tried to change the formatting to
    dd "day," h: "hours," mm "minutes. I got 2 days, 18 hours 07 minutes which is wrong! How to fix that?
    Thanks

    • Hello Khalid!
      The date format in Excel cannot show the number of days greater than 31. Therefore, try to use such a custom time format

      m"month," d"day," hh"hours," mm"minutes"

  2. Hi how could i calculate the Night duty hrs which is inside the total hours & btn 22 to 06
    Id of Crew|Name |In |Out |D.Hrs|Night D.Hrs
    N10001 |AAA |05-06-2020 16:00|05-06-2020 23:00|07:00|01:00 (btn 22 to 06)
    N10002 |BBB |06-06-2020 23:00|07-06-2020 08:00|09:00|08:00 (btn 22 to 06)
    N10006 |XYX |08-06-2020 03:00|09-06-2020 23:30|20:30|03:00 (btn 22 to 06)
    N10010 |LMN |08-06-2020 21:00|08-06-2020 23:45|02:45|01:45 (btn 22 to 06)

  3. Hi how could i calculate the total time lapse i tried =sum(f2:f4) but its not working

  4. Can Excel actually figure out the time of 1:75 is actually 135 minutes?

  5. Can Excel actually convert the time from 1:45 to 1.75 through a formula?

  6. I want to add up hours for an employee and then multiply those hours by her rate to get total cost spent. How can I do this if the hour is in this format hh:mm:ss? The formula needs a whole number like 1.75 rather than 1:45.

    • Hello!
      To convert time to number of hours, and minutes to decimal parts of an hour, use the formula

      =HOUR(D1)+MINUTE(D1)/60

      Hope this is what you need.

  7. I would like to record 24h00 in Excel 2013

    • Hello Seleko!
      Please go to Format Cells, choose Number -> Custom Format and set
      [hh]:mm:ss;@

      I hope this will help, otherwise please do not hesitate to contact me anytime.

  8. Hello!
    Any one please help!
    i need to assign formula, if employee works after 9:00pm i need give one food allowance.

    • Hello Bharath!
      Supposing your end time is in B2, the formula below will be the one for you:
      =IF(B2 < TIME(21,0,0), B2 - TIME(21,0,0) + 1,B2 - TIME(21,0,0))

  9. I have custom formatted cells with 00/:00 enable simple entry just directly key in number for instant 830 will display 8:30am,but when come to calculating the duration it display hh:mm, may I know how can I get it converted to single minute unit please.

  10. Hello,
    Is there any format that will make my time inputs in PM only. SO if I type in 5:00 it will automatically pick it up as PM and not AM.

  11. Hi, I want to record only time of a data entry is it possible to do so?

  12. I am trying to input hours in one column for example input and subtract
    in one column i have 24:13 minutes to be deducted from 113:45 minutes when i input 24:13 it changes to 0:13 also the current formula i use is =(C3-B4) where C3 is 113:45 and B4 is 24:13

    Thanks

  13. Hi,

    I've a doubt, i want to compare two columns in Time format and highlight the one that exceeded. I can only able to compare it, but I would like to know how to highlight it?

    For example:
    Shift time Login Time Status
    2:30 2:25 Met
    2:30 2:29 Met
    2:30 2:45 NotMet
    2:30 2:15 Met
    2:30 3:15 NotMet
    2:30 2:50 NotMet
    I can compare whether the condition is met or not, but how to highlight the cells in 2nd column automatically.

  14. Hi,
    How can I just display time instead of date & time in the cell. As I need 22:00 but the cell will show 14/05/1903 10:00:00pm.

  15. i am trying to create a timesheet that will limit the amount of "time worked" in a cell to 12 hours, because everything over 12 hours is considered overtime i was fairly certain my formula would be =IF ((C1-B1, "h:mm:ss") *24) > 12 , 12 ,(C382-B382, "h:mm:ss") but i keep getting a #ERROR, i have tried multiple different variations and cant seem to get this to work. any suggestions?

  16. I need a small help that I am unable to convert hours into seconds as I have been trying 7:00/ 1440 for this I am getting a perfect answer but as coming to 6:30/1440 the calculator answer and this answer is not matching can you help me with this ?

  17. How can I convert days, hours, minutes, seconds to time format Hh:mm:ss with a formula? The data in excel was extracted from a database and not formatted as an actual time format.
    Example: Convert 4 days, 22 hours, 36 minutes, 58 seconds to 118:36:58

  18. hi madam,
    I have one doubt , i am key in excel my workers overtime day shift time in 6.00 out 19.30 i use formula =((19.30-06.00)-9) 4.30 , 9 meaning company hours the rest overtime this is good result , but night shift how to use formula, in 18.00 out 08.00 , please madam can you explain me formula.

  19. Hi Svetlana,
    Good day!
    Could you please let me know how to convert 1/2/1900 2:57:10 AM data format to HH:MM:SS. I have an excel full of different types of values (12:15:34 AM, 1/2/1900 2:57:10 AM). Any help would be appreciated. Thanks

  20. IF 17:30PM-9:00AM=8:30 HOURS OR 16:30PM-9:30AM=7HOURS THAN HOW TO I KNOW 31 DAYS CALCULATION IN EXCEL

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)