Posts epoch (utc) to date
Post
Cancel

epoch (utc) to date

![vba](https://i.imgur.com/Hj0xlLe.png)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Private Sub CommandButton1_Click()

    'for the first 2 rows (@ col A there is the epoch value)
    For i = 1 To 2
        Cells(i, 2).Value = AddHour(Epoch2Date(Cells(i, 1).Value))
    Next i

End Sub

'src - http://www.vbforums.com/showthread.php?805245-EPOCH-to-Date-and-vice-versa&p=4934911&viewfull=1#post4934911
Function Epoch2Date(ByVal E As Currency) As Date
Const Estart As Double = #1/1/1970#

  msFrac = 0
  If E > 10000000000@ Then E = E * 0.001: msFrac = E - Int(E)
  Epoch2Date = Estart + (E - msFrac) / 86400
End Function

'src - https://stackoverflow.com/a/31439538/1320686
Function AddHour(ByVal sTime As String) As String
    Dim dt As Date

    dt = CDate(sTime)
    dt = DateAdd("h", 3, dt)

    'ref - https://docs.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/format-function-visual-basic-for-applications
    AddHour = Format(dt, "dd/mm/yyyy hh:nn")
End Function

not worked for me - Convert Between Date And Unix Timestamp In Excel

origin - https://www.pipiscrew.com/?p=15168 epoch-utc-to-date

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags