Time formatting in Excel: 12/24 hour, custom, default (2024)

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: 12/24 hour, custom, default (1)

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.Time formatting in Excel: 12/24 hour, custom, default (2)

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.Time formatting in Excel: 12/24 hour, custom, default (3)

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.Time formatting in Excel: 12/24 hour, custom, default (4)

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.Time formatting in Excel: 12/24 hour, custom, default (5)

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.

CodeDescriptionDisplays as
hHours without a leading zero0-23
hhHours with a leading zero00-23
mMinutes without a leading zero0-59
mmMinutes with a leading zero00-59
sSeconds without a leading zero0-59
ssSeconds with a leading zero00-59
AM/PMPeriods 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.

FormatDisplays as
h:mm:ss AM/PM1:30:00 PM
h:mm AM/PM1: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")Time formatting in Excel: 12/24 hour, custom, default (6)

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.

FormatDisplays as
h:mm:ss13:30:00
h:mm13: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")Time formatting in Excel: 12/24 hour, custom, default (7)

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:

FormatDisplays asExplanation
[h]:mm41:3041 hours and 30 minutes
[h]:mm:ss41:30:1041 hours, 30 minutes and 10 seconds
[h] "hours", mm "minutes", ss "seconds"40 hours, 30 minutes, 10 seconds
d h:mm:ss1 17:30:101 day, 17 hours, 30 minutes and 10 seconds
d "day" h:mm:ss1 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:

FormatDisplays as
d-mmm-yy h:mm:ss AM/PM13-Jan-25 1:30:00 PM
mmmm dd, hh:mm AM/PMJanuary 13, 01:30 PM
dddd, m/d/yy h:mm:ssMonday, 1/13/25 13:30:00
ddd, mmmm dd, yyyy hh:mmMon, 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:

FormatDisplays as
h:mm:ss AM/PM1:30:00 PM
hh:mm:ss AM/PM01:30:00 PM
hh:mm:ss13:30:00
hh-mm-ss13-30-00
hh.mm.ss13.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.Time formatting in Excel: 12/24 hour, custom, default (8)

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.Time formatting in Excel: 12/24 hour, custom, default (9)

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.Time formatting in Excel: 12/24 hour, custom, default (10)

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)

You may also be interested in

  • How to insert current date and time in Excel
  • How to calculate time in Excel
  • How to subtract Excel numbers, percentages, dates and times
  • How to divide in Excel and handle #DIV/0! error
Time formatting in Excel: 12/24 hour, custom, default (2024)

References

Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 5878

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.