YTD numbers are based on the paycheck date, and are the sum of payroll for that date's year - for each line item on the pay stub.
Similarity, all payroll tax forms and other payroll reporting to agencies is based on the payroll date (the paycheck date). The pay period is not relevant.
So, for example, your Jan 7, 2024 paychecks will be included on your 2024 W-2's, not your 2023 W-2's.