Update dateandtime.txt
EpochTime() function example
Input:    Date(), Time()
Output: Epoch seconds
@@ -214,3 +214,56 @@ Example:
see cDate2 + nl # 03/06/2015
see "DiffDays = " + diffdays(cDate1,cDate2) + nl # -10
see "DiffDays = " + diffdays(cDate2,cDate1) + nl # 10
+
+.. index::
+ pair: Date and Time; EpochTime()
+
+EpochTime() Function
+==================
+
+Syntax:
+
+.. code-block:: ring
+
+ EpochTime( Date(), Time() ) ---> Epoch Seconds
+
+Example:
+
+.. code-block:: ring
+
+ ###-------------------------------------------------------------
+ # EpochTime()
+ # Example --- EpochSec = EpochTime( Date(), Time() )
+ # Call Format: EpochSec = EpochTime( "15/07/2016", "10:15:30" )
+ # EpochSec = 1468577730
+ #---------------------------------------------------------------
+
+ Func EpochTime(Date, Time)
+
+ arrayDate = split(Date, "/")
+ arrayTime = split(Time, ":")
+
+ Year = arrayDate[3] ; Month = arrayDate[2] ; Day = arrayDate[1]
+ Hour = arrayTime[1] ; Minute = arrayTime[2] ; Second = arrayTime[3]
+
+ cDate1 = Day +"/"+ Month +"/"+ Year
+ cDate2 = "01/01/" + Year
+ DayOfYear = DiffDays( cDate1, cDate2)
+
+ ### Formula
+ tm_sec = Second * 1
+ tm_min = Minute * 60
+ tm_hour = Hour * 3600
+ tm_yday = DayOfYear * 86400
+ tm_year = Year - 1900
+
+ tm_year1 = ( tm_year - 70) * 31536000
+ tm_year2 = ( floor(( tm_year - 69) / 4 )) * 86400
+ tm_year3 = ( floor(( tm_year - 1) / 100 )) * 86400
+ tm_year4 = ( floor(( tm_year + 299) / 400 )) * 86400
+
+ ### Result
+ EpochSec = tm_sec + tm_min + tm_hour + tm_yday + tm_year1 + tm_year2 - tm_year3 + tm_year4
+
+ return EpochSec
+
