Try now in the
Open Cloud »
(no sign-in required)

Age in Days, Hours, etc.

You know your age in years; how about in days?

Enter a date:

SHOW/HIDE DETAILS

DateObject gives you an exact date that you can do computations with:

DateObject["November 16, 1998"]

It understands most common date formats:

DateObject["11/16/98"]
DateObject["16.11.98"]
DateObject["1998 Nov 16"]

HIDE DETAILS
DateObject["November 16, 1998"]

Run the code to compute the number of days from now back to a date. Try other dates:

SHOW/HIDE DETAILS

Now gives you the date and time at the instant you run it:

Now

Subtract a date from Now to find the number of days back to the date:

Now -DateObject["November 16, 1998"]

HIDE DETAILS
Now - DateObject["November 16, 1998"]

Round to whole days. Try other dates:

SHOW/HIDE DETAILS

Round rounds decimal numbers to integers:

Round[4.56]

Round a date computation to get an answer in whole days:

Round[Now - DateObject["November 16, 1998"]]

HIDE DETAILS
Round[Now - DateObject["November 16, 1998"]]

Convert to minutes. Try other dates, like your birthday (to find out how many minutes old you are):

SHOW/HIDE DETAILS

UnitConvert converts between different units, like grams and pounds, or days and minutes.

This gives an answer in days:

Round[Now - DateObject["November 16, 1998"]]

Convert the result to minutes:

UnitConvert[Round[Now - DateObject["November 16, 1998"]], "Minutes"]

HIDE DETAILS
Round[UnitConvert[Now - DateObject["November 16, 1998"], "Minutes"]]

Spell out the result. Try other dates:

SHOW/HIDE DETAILS

The result of a date calculation has both a value (the number) and a unit (min):

Round[UnitConvert[Now - DateObject["November 16, 1998"], "Minutes"]]

Use QuantityMagnitude to get just the value:

QuantityMagnitude[ Round[UnitConvert[Now - DateObject["November 16, 1998"], "Minutes"]]]

IntegerName gives the spelled-out names of numbers:

IntegerName[1234567]

Spell out the result of a date calculation:

IntegerName[ QuantityMagnitude[ Round[UnitConvert[Now - DateObject["November 16, 1998"], "Minutes"]]]]

HIDE DETAILS
IntegerName[ QuantityMagnitude[ Round[UnitConvert[Now - DateObject["November 16, 1998"], "Minutes"]]]]

Get the result in seconds. Try other units, like "Hours", "Weeks" or "Months":

IntegerName[ QuantityMagnitude[ Round[UnitConvert[Now - DateObject["November 16, 1998"], "Seconds"]]]]

Share ItMake a website that tells you how many days old you are. Try making a site that tells you how many seconds old you are:

SHOW/HIDE DETAILS

Deploy the days old calculation to make a website where you can enter a birthdate and find out how many days old you are:

CloudDeploy[FormFunction[{"birthdate" -> "Date"}, Round[Now - DateObject[#birthdate]] &, "PNG" ], Permissions -> "Public"]

Click the link in the output to visit the site.

Format the output more nicely using Row:

CloudDeploy[FormFunction[{"birthdate" -> "Date"}, Row[{"You are ", QuantityMagnitude[Round[Now - DateObject[#birthdate]]], " days old."}] &, "PNG" ], Permissions -> "Public"]

Make the text larger:

CloudDeploy[FormFunction[{"birthdate" -> "Date"}, Style[Row[{"You are ", QuantityMagnitude[Round[Now - DateObject[#birthdate]]], " days old."}], 48] &, "PNG" ], Permissions -> "Public"]

Click the link in the output to visit the site.

Tell the world about your creation by sharing the link via email, tweet or other message.

HIDE DETAILS
CloudDeploy[FormFunction[{"birthdate" -> "Date"}, Style[Row[{"You are ", QuantityMagnitude[Round[Now - DateObject[#birthdate]]], " days old."}], 48] &, "PNG" ], Permissions -> "Public"]