#Time
#ampm
Return am or pm. Very simple.
#date
Generate a random date
By default, returns an actual Date object
Can optionally specify that a date be returned as a string
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
.
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.
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
Generate a random hammertime.
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
Generate a random hour
By default, returns an hour from 1 to 12 for a standard 12-hour clock.
Can optionally specify a full twenty-four.
This will return an hour from 1 to 24.
#millisecond
Generate a random millisecond
By default, returns a millisecond from 0 to 999. Idea is for generating a clock time.
#minute
Generate a random minute
By default, returns a minute from 0 to 59. Idea is for generating a clock time.
#month
Generate a random month.
By default, returns just the full name.
Optionally specify raw to get the whole month object consisting of name, short_name, and numeric.
#second
Generate a random second
By default, returns a second from 0 to 59. Idea is for generating a clock time.
#timestamp
Generate a random timestamp. This is a standard Unix time, so a random number of seconds since January 1, 1970.
#timezone
Return a random timezone
#weekday
Return a weekday
By default, weekday_only is false. If set to true it will never return Saturday or Sunday.
#year
Generate a random year
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:
Optionally specify min, max, or both to limit the range.