date problem

ugokhan

Member
Licensed User
Longtime User
Hello !

Any date up to the date of 01.01.1970 How do I calculate elapsed time in seconds. For example, mktime function in php like.
 

ugokhan

Member
Licensed User
Longtime User
I looked at the links above. I have a problem also.
Adding up the two date is not always true. Therefore, a simple loop written as follows.
(my english is not good. I'm sorry everyone)

B4X:
Sub Activity_Create(FirstTime As Boolean)
     DateTime.DateFormat = "dd.MM.yyyy"
End Sub

Sub Button1_Click
   Dim date1 As Long
   Dim date2 As Long
   Dim answer As String
   Dim TKS As Long
   TKS = 86400000  'millisecond-to-day coefficient
   
   date1 = DateTime.DateParse("08.10.2012")
   
   For i=1 To 60
      date2 = i*TKS
      answer = DateTime.Date(date1+date2)
      ListView1.AddSingleLine (i & ". " & answer)
   Next
End Sub

The same dates of the 20th and 21st rows, in the application screen
19. 27.10.2012
20. 28.10.2012
21. 28.10.2012

22. 29.10.2012
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
If you want to add days to a given date here is what you want:
B4X:
Dim i As Int
Dim Listview1 As ListView
'Listview1.Initialize("Listview1")      'must be commented if created in the designer
Dim MyDate(60) As String
DateTime.DateFormat = "dd.MM.yyyy"
For i=0 To 59   '60 dates
   MyDate(i)=DateTime.Date(DateTime.Add(DateTime.Dateparse("8.10.2012"),0,0,i))  
   Listview1.AddSingleLine (i & ". " & MyDate(i))
Next
'   Msgbox(MyDate(0) & "  " & MyDate(1) & "  " & MyDate(2) & "  " & MyDate(3) & "  " & MyDate(4),"")
Msgbox(MyDate(18) & "  " & MyDate(19) & "  " & MyDate(20) & "  " & MyDate(21) & "  " & MyDate(22),"")
The last msgbox will show you: 26.10.2012 27.10.2012 28.10.2012 29.10.2012 30.10.2012
 
Last edited:
Upvote 0
Top