Master timestamp formats and conversions for date/time handling.
Timestamps are a way to represent a specific moment in time. They are essential for logging, event tracking, and data synchronization.
#
A timestamp is a sequence of characters or encoded information identifying when a certain event occurred.
#
Unix Timestamp (Seconds):
Unix Timestamp (Milliseconds):
ISO 8601:
#
The Unix epoch is January 1, 1970, 00:00:00 UTC. This is the reference point for Unix timestamps.
#
#
``javascript
// Get current timestamp in milliseconds
const timestamp = Date.now();
// Convert to date object const date = new Date(timestamp);
// Format as ISO string const isoString = date.toISOString();
// Parse ISO string const parsedDate = new Date('2024-01-01T00:00:00Z'); ``
#
#
Best Practices:
1. Store timestamps in UTC 2. Convert to local time only for display 3. Use ISO 8601 format for string representation 4. Be aware of daylight saving time changes
#
RFC 2822:
Custom Formats:
#
#
Unix epoch is January 1, 1970, 00:00:00 UTC - the reference point for Unix timestamps.
Millisecond timestamps have 3 extra digits and provide higher precision.
Always store in UTC. Convert to local time only for display.
Use date/time libraries in your programming language (e.g., Date object in JavaScript).
ISO 8601 is an international standard for date/time representation (e.g., 2024-01-01T00:00:00Z).
Use toLocaleString() for local time or toISOString() for UTC.
Yes, negative timestamps represent dates before January 1, 1970.
For 32-bit systems: 2147483647 (January 19, 2038). For 64-bit: much larger.
Try our tools to apply what you have learned in real-time.