Use these Excel formulas to generate Unix timestamp (epoch) from any date/time or the current time. Includes seconds, milliseconds, timezone adjustments, and rounding.
A1 contains a valid Excel date/time (UTC)
= (A1 - DATE(1970,1,1)) * 86400
A1 contains a valid Excel date/time (UTC)
= (A1 - DATE(1970,1,1)) * 86400 * 1000
Generate current Unix time (seconds)
= (NOW() - DATE(1970,1,1)) * 86400
Generate current Unix time (milliseconds)
= (NOW() - DATE(1970,1,1)) * 86400 * 1000
If A1 is local time and your system is UTC+8, convert to UTC then to epoch (seconds)
= (A1 - (8/24) - DATE(1970,1,1)) * 86400
Round down to whole seconds (avoid fractions)
= INT((A1 - DATE(1970,1,1)) * 86400)