SetTimeZone(0) before every DateTime method?
Hi all
I am trying this code and the result of c is not 01:00:00 if the timezone of my device is not 0.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I order to have correct result i change the code like this:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Is this correct way?
In what methods of the DateTime And the DateUtils this trick must be done in order to have correct results from them? What methods are affected by the timezone?
			
			Hi all
I am trying this code and the result of c is not 01:00:00 if the timezone of my device is not 0.
			
				B4X:
			
		
		
		Dim a As Long
   Dim b As Long
   Dim c As Long
   a = DateTime.Now
   b = a - DateTime.TicksPerHour
   Log (DateTime.Time(a))
   
   Log (DateTime.Time(b))
   
   c = a - b
   
   Log (DateTime.Time(c))I order to have correct result i change the code like this:
			
				B4X:
			
		
		
		Dim a As Long
   Dim b As Long
   Dim c As Long
   Dim Timezone As Double
   Timezone = DateTime.GetTimeZoneOffsetAt(DateTime.Now)
   
   a = DateTime.Now
   b = a - DateTime.TicksPerHour
   
   DateTime.SetTimeZone(0)
   
   Log (DateTime.Time(a))
   
   Log (DateTime.Time(b))
   
   c = a - b
   
   Log (DateTime.Time(c))
   
   DateTime.SetTimeZone(Timezone)Is this correct way?
In what methods of the DateTime And the DateUtils this trick must be done in order to have correct results from them? What methods are affected by the timezone?
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
 
		 
 
		 
 
		 
 
		