convert a time to unix timestamp

pigsfoot

Board Regular
Joined
Dec 13, 2007
Messages
58
Office Version
  1. 365
Hi,
Is it possible to convert a time only to a unix timestamp. Everything i have found reffers to a date rather than time.

i.e. Time 00:15:00 = 1638317700

where A2 = 00:00:00 and the cell is formatted as Time

I just need a formula to work that out please.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
To convert to a Unix timestamp, you have to include the date. A Unix timestamp is the number of seconds since Jan 1, 1970. Do you want to assume that your time is on the current date?

This will give the Unix timestamp for a given date+time:
VBA Code:
Dim DateTime As Date
DateTime = Now
DateDiff("s", "1/1/1970", DateTime)

This will do it when your date is TODAY:
VBA Code:
Dim TimeOnly As Double
TimeOnly = TimeValue("00:15:00")
DateDiff("s", "1/1/1970", Date + TimeOnly)
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top