Skip to content

Time Information

The /time endpoint allows you to retrieve time information based on various parameters. You can get the current time or a random time between a specified range, in different formats and time zones.

Parameters

ParameterRequiredDescription
typeNolive (default) for current time, random for a random time, countdown for time until a target
startNoStart date for random range (format: YYYY-MM-DD)
endNoEnd date for random range (format: YYYY-MM-DD)
targetNoTarget date for countdown mode (format: YYYY-MM-DD or ISO 8601)
formatNoResponse format (see options below)
timezoneNoTime zone to use (see options below)

Format Options

FormatDescription
isoISO 8601 format (default)
utcUTC format
timestampUnix timestamp
localeLocal format
dateDate in MM/DD/YYYY format
timeTime in HH:MM:SS format
yearYear only
monthMonth only
dayDay only
hourHour only
minuteMinutes only
secondSeconds only
msMilliseconds only
dayOfWeekDay of the week (0-6)
dayOfYearDay of the year (1-365/366)
weekNumberWeek number
timezoneTime zone name

Timezone Options

TimezoneDescription
UTCCoordinated Universal Time (default)
Europe/ParisParis time zone
America/New_YorkNew York time zone
Asia/TokyoTokyo time zone
Australia/SydneySydney time zone

Response Fields

FieldTypeDescription
isostringDate in ISO 8601 format
utcstringDate in UTC string format
timestampnumberUnix timestamp
localestringLocalized date and time string
datestringDate in MM/DD/YYYY format
timestringTime in HH:MM:SS format
yearnumberYear
monthnumberMonth (1-12)
daynumberDay of the month
hournumberHour (0-23)
minutenumberMinutes
secondnumberSeconds
msnumberMilliseconds
dayOfWeeknumberDay of the week (0-6)
dayOfYearnumberDay of the year (1-365/366)
weekNumbernumberWeek number of the year
timezonestringTime zone name
timezoneOffsetstringUTC offset of the time zone

Code Examples

curl -X GET \
  "https://api.sylvain.sh/v4/time?type=random&format=locale&timezone=America%2FNew_York"

Try It

Error Handling

If parameters are invalid, the API will return an error:

Error MessageDescription
Please provide a valid type (?type={type})The type parameter is invalid
Please provide a valid start date (?start={YYYY-MM-DD})The start parameter is invalid
Please provide a valid end date (?end={YYYY-MM-DD})The end parameter is invalid
Please provide a valid target date (?target=...)The target parameter is invalid
Please provide a valid format (?format={format})The format parameter is invalid
Please provide a valid timezone (?timezone={timezone})The timezone parameter is invalid