Date to Binary Date Converter
Convert calendar dates to binary representation. Transform year, month, day into binary code with configurable bit widths and formats.
Select a date and click Convert to see binary representation
Bit Width Reference
Day (1-31): 5 bits minimum, typically stored in 8 bits
Month (1-12): 4 bits minimum, typically stored in 8 bits
Year (0-9999): 14 bits minimum, typically stored in 16 bits
Unix Timestamp: 32 bits (signed) or 64 bits for dates beyond 2038
About
Date encoding in binary format serves critical functions in embedded systems, network protocols, and low-level data storage where memory efficiency determines system viability. The conversion process isolates each date component - year (Y), month (M), day (D) - and transforms them independently using positional notation with base 2. A year like 2024 requires 11 bits minimum (211 = 2048), while months fit in 4 bits and days in 5 bits. Miscalculating bit allocation causes overflow errors that corrupt downstream data - a 1-bit error in date storage propagates through entire database records.
This converter handles both component-wise conversion and Unix timestamp binary encoding. Unix timestamps represent seconds elapsed since 1970-01-01T00:00:00Z, requiring 32 bits until the Year 2038 problem forces migration to 64-bit representations. The tool validates against impossible dates (February 30, Month 13) and accounts for leap year rules including the 400-year Gregorian correction. Output includes both raw binary and zero-padded fixed-width formats required by most protocol specifications.
Formulas
Binary conversion applies the division-remainder algorithm. For any decimal integer n, repeatedly divide by 2 and collect remainders in reverse order.
where bi ∈ {0, 1} represents each binary digit. The minimum bit width required for value n is:
For zero-padded fixed-width output, prepend (W − w) zeros where W is the target width. Unix timestamp conversion first calculates seconds elapsed since the epoch:
then applies the same base-2 conversion to t. MS-DOS packed date format uses bit fields: 7 bits for year offset from 1980, 4 bits for month, 5 bits for day, concatenated into a 16-bit word.
Reference Data
| Date Component | Value Range | Minimum Bits | Standard Width | Binary Example |
|---|---|---|---|---|
| Day | 1 - 31 | 5 bits | 8 bits | 00011111 (31) |
| Month | 1 - 12 | 4 bits | 8 bits | 00001100 (12) |
| Year (Short) | 0 - 99 | 7 bits | 8 bits | 01100011 (99) |
| Year (Full) | 1 - 9999 | 14 bits | 16 bits | 0000011111101000 (2024) |
| Unix Timestamp | 0 - 2147483647 | 31 bits | 32 bits | 01100101... |
| Hour | 0 - 23 | 5 bits | 8 bits | 00010111 (23) |
| Minute/Second | 0 - 59 | 6 bits | 8 bits | 00111011 (59) |
| Week Number | 1 - 53 | 6 bits | 8 bits | 00110101 (53) |
| Day of Year | 1 - 366 | 9 bits | 16 bits | 0000000101101110 (366) |
| Century | 0 - 99 | 7 bits | 8 bits | 00010100 (20) |
| Decade | 0 - 9 | 4 bits | 8 bits | 00000010 (2) |
| Quarter | 1 - 4 | 2 bits | 8 bits | 00000100 (4) |
| Weekday (ISO) | 1 - 7 | 3 bits | 8 bits | 00000111 (7) |
| MS-DOS Date | Packed 16-bit | 16 bits | 16 bits | YYYYYYYM MMMDDDDD |
| Julian Day Number | 0 - 5373484 | 23 bits | 32 bits | Astronomical dating |
| Modified Julian | 0 - 99999 | 17 bits | 32 bits | Space/telecom standard |
| Excel Serial Date | 1 - 2958465 | 22 bits | 32 bits | Days since 1900-01-01 |
| BCD Date (packed) | 6 digits | 24 bits | 24 bits | YYMMDD in BCD |
| GPS Week Number | 0 - 1023/8191 | 10/13 bits | 16 bits | Weeks since 1980-01-06 |
| TAI64 Label | 64-bit | 64 bits | 64 bits | Seconds since TAI epoch |