# Time

# ampm

// usage

Return am or pm. Very simple.

=> 'am'

# date

// usage
{{date({string: true})}}
{{date({string: true, american: false})}}
{{date({year: 1983})}}

Generate a random date

=> Sat Apr 09 2072 00:00:00 GMT-0400 (EDT)

By default, returns an actual Date object

Can optionally specify that a date be returned as a string

{{date({string: true})}};
=> "5/27/2078"

This will return a date string of the format MM/DD/YYYY.

Now of course MM/DD/YYYY is the "American" date method, but it's the default because there isn't much support for internationalization here yet. Further, it's the format used by Facebook and other services for birthdays and other non-Date object dates.

However, we support returning dates in DD/MM/YYYY format as well when requesting a date by a string and passing american: false.

{{date({string: true, american: false})}};
=> "13/2/2017"

If you want richer control over date format, strongly suggest using the Moment library. Our formatting is very minimalist, and it's out of our core competency to offer dates in a myriad of formats.

Can optionally specify defaults for any of day, month, or year.

{{date({year: 1983})}};
=> Wed May 04 1983 00:00:00 GMT-0400 (EDT)

{{date({month: 0})}};
=> Tue Jan 18 2084 00:00:00 GMT-0500 (EST)

{{date({day: 21})}};
=> Sun Oct 21 2103 00:00:00 GMT-0400 (EDT)

A random date is generated, but the default you specify is kept constant.

Note, month is 0-indexed. This is a carryover from the core JavaScript Date object which we use internally to generate the date.

# hammertime

// usage

Generate a random hammertime.

=> 2273327300317

Hammertime is the name given to a Unix time with milliseconds. Which is the same as saying the number of milliseconds since 1970. It has finer granularity than a normal Unix timestamp and thus is often used in realtime applications.

According to startup lore, Hammertime was coined by a startup whose founder had an interesting interaction with M.C. Hammer. There was no name given to "Unix time with milliseconds" and while brainstorming ideas (because Unix time with milliseconds is a confusing mouthful), someone suggested Hammertime and it stuck.

# hour

// usage
{{hour({twentyfour: true})}}

Generate a random hour

=> 9

By default, returns an hour from 1 to 12 for a standard 12-hour clock.

Can optionally specify a full twenty-four.

{{hour({twentyfour: true})}};
=> 21

This will return an hour from 1 to 24.

# millisecond

// usage

Generate a random millisecond

=> 729

By default, returns a millisecond from 0 to 999. Idea is for generating a clock time.

# minute

// usage

Generate a random minute

=> 35

By default, returns a minute from 0 to 59. Idea is for generating a clock time.

# month

// usage

Generate a random month.

=> 'January'

By default, returns just the full name.

Optionally specify raw to get the whole month object consisting of name, short_name, and numeric.

{{month({raw: true})}};
=> {name: 'October', short_name: 'Oct', numeric: '10'}

# second

// usage

Generate a random second

=> 19

By default, returns a second from 0 to 59. Idea is for generating a clock time.

# timestamp

// usage

Generate a random timestamp. This is a standard Unix time, so a random number of seconds since January 1, 1970.

=> 576556683

# timezone

// usage

Return a random timezone

=> {
"name": "India Standard Time",
"abbr": "IST",
"offset": 5.5,
"isdst": false,
"text": "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi",
"utc": ["Asia/Calcutta"]

# weekday

// usage
{{weekday({weekday_only: true})}}

Return a weekday

=> 'Tuesday'

By default, weekday_only is false. If set to true it will never return Saturday or Sunday.

# year

// usage
{{year({min: 1900, max: 2100})}}

Generate a random year

=> '2053'

By default, min is the current year and max is 100 years greater than min.

This is returned as a string. If for some reason you need it numeric, just parse it:

=> 2042

Optionally specify min, max, or both to limit the range.

{{year({min: 1900, max: 2100})}};
=> '1983'