Table of Contents

Class TimeProvider

Namespace
Vonage.Common
Assembly
Vonage.dll

Default implementation of ITimeProvider that returns the actual system time.

public class TimeProvider : ITimeProvider
Inheritance
TimeProvider
Implements
Inherited Members

Remarks

For unit testing, consider creating a mock implementation that returns controlled time values.

Properties

Epoch

Gets the current time as a Unix timestamp (seconds since January 1, 1970 UTC).

public long Epoch { get; }

Property Value

long

Examples

long timestamp = timeProvider.Epoch;
// Example: 1704067200 (represents 2024-01-01 00:00:00 UTC)

UtcNow

Gets the current UTC date and time.

public DateTime UtcNow { get; }

Property Value

DateTime

Examples

DateTime now = timeProvider.UtcNow;