time(
time(
TIME
)

The time( function converts text into a number representing a time.

Parameters

This function has one parameter:

time – the text that is to be converted into a time value.

Description

The time( function converts text into a number representing a time. (Note: The seconds( function is a synonym for the *time(* function, and works exactly the same.) The function returns a number representing the time. The number is the number of seconds since midnight. For example, if the time parameter is 10:23 AM this function will return the number 37,380.

The time( function tries very hard to understand the time you give it. It will accept a time without colons, for example 425 pm instead of 4:25 pm. If there is no am or pm the time function will assume it is 24 hour time.

The time( function will also convert named times: noon, midnight, morning, afternoon, evening, and night. By default the function assumes that morning is 9:00 am, afternoon is 1:00 pm, evening is 6:00 pm, and night is 10:00 pm.

Here are some examples of times that this function understands:

    4:13 PM
    11:00 AM
    2:30
    18:45
    230
    4p
    midnight
    noon
    morning
    afternoon
    evening
    night
    nite

Note: If you want to enter a time that is beyond 24 hours (for example an elapsed time) then you must use separators between the hours, minutes and seconds, like this:

    86:45:02

You can use any punctuation character you like as a separator, including spaces or periods, however, there must be only one separator character between each number.

Error Messages

Illegal time – This error appears if a valid time is not specified. For example two o’clock is not a format that this function understands.

See Also

- converttimezone( -- converts a time or superdate from one time zone to another.
- daylightsavingstimeoffset( -- returns the current daylight saving time offset of the specified time zone.
- info("localtimezone") -- returns the local time zone for the current location of your computer.
- info("milliseconds") -- returns the number of milliseconds (1/1000th second) since the system started up.
- info("tickcount") -- returns the number of ticks (1/60th second) since the system started up.
- info("timezoneabbreviations") -- returns a dictionary of time zone abbreviations supported by the system.
- info("timezones") -- returns a list of time zone regions recognized by the system.
- longtimestr( -- converts a number to text in am/pm time format, including seconds.
- nextdaylightsavingstimetransition( -- returns the next date on which a transition to or from daylight savings time occurs.
- now( -- returns the current time (number of seconds since midnight).
- regulartime( -- extracts a regular time (seconds since midnight) from a superdate.
- secsminshours( -- this converts a time (number of seconds) into an approximate text value.
- superdate( -- converts a regular date and a regular time into a superdate.
- superdatepattern( -- converts a number containing a superdate to text, allowing you to specify the patterns for both the date and the time conversion to text.
- superdatesecondsstr( -- converts a number containing a superdate to text, including the seconds.
- superdatestr( -- converts a number containing a superdate (date + time) to text.
- supernow( -- returns the number representing the current date and time as a superdate.
- texttimedifference( -- allows time math to be performed on text values.
- texttimeinterval( -- allows time math to be performed on text values.
- time24( -- takes a time and makes sure it falls within a 24 hour period.
- timedifference( -- calculates the difference between two times. It works correctly even if the interval between the two times crosses over midnight.
- timeinterval( -- calculates the time interval between two times. It works correctly even if the interval between the two times crosses over midnight.
- timepattern( -- converts a number representing a time into text. The function uses a pattern to control how the time is formatted.
- timestr( -- converts a number to text in am/pm time format.
- timezoneabbreviation( -- returns the abbreviation of the specified time zone.
- timezonename( -- returns the continent and city of the specified time zone.

History

Version | Status | Notes
10.0 | Updated | The time( and seconds( functions have been combined, now both work exactly the same.