• Returns an Atom that automatically updates its value to the current time at the given interval. The interval is specified in milliseconds and defaults to 1000. When there are subscribers, the Atom updates its value at the specified interval. When there are no subscribers, the interval is cleared and the Atom's value is reset to 0.

    Parameters

    • Optional interval: number = 1000

      The interval in milliseconds at which the Atom should update its value.

    Returns Atom<number>

    An Atom that automatically updates its value to the current time at the given interval.

    Example

    const now = getNow();
    console.log(now.value); // 0

    const unsubscribe = now.subscribe(() => {
    console.log(now.value); // Current time in milliseconds
    });