NaviServer - programmable web server

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_time(n) 4.99.19 naviserver "NaviServer Built-in Commands"

Name

ns_time - Perform various time-related functions

Table Of Contents

Synopsis

Description

This command provides various time-related functions. Times might be of the form "sec" (integer value), "sec:usec" (NaviServer internal format) or "sec.fraction" (such as the result of ns_time format). The allowed options of ns_time are:

COMMANDS

ns_time ?arg arg ...?
ns_time

Returns the seconds portion of the current time.

ns_time adjust time

Adjusts time so that it is within the valid range of values for a time. (TODO: Figure out how this is actually useful.)

ns_time diff time1 time2

Computes the time difference between time1 to time2. It does this by subtracting time1 from time2 and returns a string in "sec:usec" format.

ns_time format time

Returns the time in seconds in the form of a real number.

ns_time get

Returns the current time in "sec:usec" format.

ns_time incr time sec ?usec?

Increments time by sec seconds and optionally usec microseconds. Returns a string in "sec:usec" format.

ns_time make sec ?usec?

Returns a string in the form "sec:usec". usec defaults to zero. If usec is zero, the colon and usec are not returned. If sec is zero, however, it is returned as part of the time string.

ns_time seconds time

Parses a time in "sec:usec" format and returns the seconds portion.

ns_time microseconds time

Parses a time in "sec:usec" format and returns the microseconds portion. It assumes zero microseconds if time only contains seconds. All times are relative to 00:00:00 UTC, January 1, 1970 a.k.a. the Unix epoch.

EXAMPLES

   % ns_time
   1087006685
   % ns_time get
   1087013247:598897
   % set t [ns_time diff $time $time3]
   0:13
   
   % ns_time format $t
   0.000013

See Also

ns_fmttime, ns_gmtime, ns_httptime, ns_localtime, ns_parsehttptime, ns_parsetime, ns_sleep

Keywords

global built-in, time