Days Since 2000
days since 2000
Category Sensing
Type Reporter
Introduced in v148 (2.0 alpha)
v230 (2.0 beta)
Removed in v172 (2.0 alpha)

The Days Since 2000 block is a Sensing block and a reporter block. It reports the number of days (and fractions of a day) since 00:00:00 1 January 2000 (UTC). It was replaced by Scratch Days in v172, but replaced Scratch Days in v230 of the 2.0 beta, and Scratch Days did not make the official release of 2.0.

It is one of the two date/time blocks in Scratch. The other is current (), which reports the date or time. Both these blocks can be worked in unison with one another for a variety of time-related scripts and projects. The days since 2000 block also updates more frequently than the timer leading to more unique use cases.

Example Uses

Comparing Dates

  • Making a countdown until an event.
say (join ((9497) - (days since 2000)) [ days till 2026!])
  • Making something unavailable before or after a certain date.
if <(days since 2000) < [9497]> then
  change [money v] by [1000]
else
  say [This feature is unavailable after January 1, 2026.]
end
  • Making idle games that support save codes. If the time is stored in the save code, the elapsed time can be found when loaded later. Consider a game where money is earned over a long time. The next time the save is loaded, the amount of money earned over that time can be calculated.
when I receive [game loaded from save v]
set [money v] to ((saved money) + ((saved money gain rate) * ((days since 2000) - (saved days since 2000))))

Animations

Animations can be based on the current time. For example a sprite can smoothly bob up and down forever with the following:

forever
  set y to (([sin v] of ((days since 2000) * (31104000))) * (10)) // period = 1 sec, amplitude = 10
end

Multiple Timers

Use a variable to store the start time of a timer. The elapsed time can be found by subtracting it from the current time.

set [timer 2 start time v] to (days since 2000) // this "set variable" block is equivalent to "reset timer"
forever
set [timer 2 v] to (((days since 2000) - (timer 2 start time)) * (86400)) // update the timer. There are 86400 seconds in a day.
end

Measuring Frame Times

Measuring the time elapsed between frames (delta time) and/or an FPS counter.

Main article: Making an FPS Counter
when flag clicked
set [last time v] to (days since 2000)
forever
set [delta time v] to (((days since 2000)-(last time)) * (86400))
set [FPS v] to (round ((1) / (delta time)))
set [last time v] to (days since 2000)
broadcast [tick v]
end

Sub-frame Times

The time reported by this block updates more frequently than Scratch's frame rate. This allows for more accurate times, essential for applications such as profiling performance.

set [start time v] to (days since 2000)
... // code to measure
set [elapsed time v] to (((days since 2000) - (start time)) * (86400))

One creative use of this is making scripts that stop after a certain time.

define example // run without screen refresh
set [start time v] to (days since 2000)
repeat (10000)
  if <(((days since 2000) - (start time)) * (86400)) > [0.0333]> then // example time limit of 1/30 sec
    stop [this script v]
  end
  ...
end

Multiplayer

  • The time can be included in data packets sent through cloud variables. Old data for example could be ignored.
  • A dynamic game world such as one with a 20-minute day/night cycle can be implemented without any need for sending this between players (all players can calculate the events happening from their own time).
set [in-game time of day v] to ((((days since 2000) * (1440)) / (20)) mod (1)) // counts from 0.0 to 1.0 every 20 min

Time Zone Estimation

The value can be compared with other date blocks to estimate a user's time zone.[1]

Controversy

Many users have questioned the usefulness of this block and what it is for.[2][3][4] Many users have also suggested the block to be replaced with a (days since ():: sensing) block.[5][6][7][8][9] The block is often used for countdowns and clocks, [10] so other users have also said that this block is useful and should not be removed.[11]

Workaround

This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.

During the Scratch 2.0 beta, this block could be replicated using the Scratch Days block:

((Scratch days::sensing) + (2691))

See Also

References