# datetime

**URL:** <https://forum.xojo.com/t/datetime/52245>\
**Category:** iOS\
**Created:** [February 3, 2020, 1:38pm UTC](https://forum.xojo.com/t/datetime/52245 "2020-02-03T13:38:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Bierman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@Dick\_Bierman](https://forum.xojo.com/u/Dick_Bierman)\
**Post date:** [February 3, 2020, 1:38pm UTC](https://forum.xojo.com/t/datetime/52245/1 "2020-02-03T13:38:08Z")

</div>

I need date and time for ios.  
The only code I could find gives me errors like DateTime non-existent type.  
But this is straight from the manual! And nowhere it says you have to code this differently for ios

`Var d As DateTime = DateTime.Now
MessageBox(d.ToString(Locale.Current))`

Thanks for any help  
Dick

---

<div class="post-metadata">

**Author:** ![DerkJ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DerkJ](https://forum.xojo.com/u/DerkJ)\
**Post date:** [February 3, 2020, 1:57pm UTC](https://forum.xojo.com/t/datetime/52245/2 "2020-02-03T13:57:34Z")

</div>

Try Xojo.core.Date  
[http://documentation.xojo.com/api/deprecated/xojo.core.date.html](http://documentation.xojo.com/api/deprecated/xojo.core.date.html)

Everything with “Xojo.\*” is for ios

---

<div class="post-metadata">

**Author:** ![Nicholas\_Loveday](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/f1d935/32.png) [@Nicholas\_Loveday](https://forum.xojo.com/u/Nicholas_Loveday)\
**Post date:** [March 16, 2020, 10:10am UTC](https://forum.xojo.com/t/datetime/52245/3 "2020-03-16T10:10:22Z")

</div>

Likewise I would like to use DateTime object in iOS… and I also need to know the timezone offset from GMT - including daylight saving (if applicable).  
Seems not possible without DateTime. The Date object doesn’t provide the timezone offset, nor daylight saving.  
The timezone can be estimated from longitude - but not reliably - as there are endless departures from that.

Also really annoying are the inverse trig functions.

On one hand sin, cos and tan are supported but to get the inverses is dreadful syntax eg:  
Xojo.maths.asin, Xojo.maths.acos, and Xojo.maths.atan2…

This “framework” stuff is an unecessarily verbose longhand that adds nothing meaningful - all it achieves is forcing me to define my own sin, acos and atan methods, as they should have been in the first place.

---

<div class="post-metadata">

**Author:** ![Jeremie\_L](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremie_l/32/150_2.png) [@Jeremie\_L](https://forum.xojo.com/u/Jeremie_L)\
**Post date:** [March 17, 2020, 12:23am UTC](https://forum.xojo.com/t/datetime/52245/4 "2020-03-17T00:23:46Z")

</div>

Xojo.core.timezone and timezone classes work the same way.

Xojo.core.date has a timezone property  
[https://documentation.xojo.com/api/deprecated/xojo.core.date.html#xojo-core-date-timezone](https://documentation.xojo.com/api/deprecated/xojo.core.date.html#xojo-core-date-timezone)

Or is it something else you needed?

---

<div class="post-metadata">

**Author:** ![Nicholas\_Loveday](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/f1d935/32.png) [@Nicholas\_Loveday](https://forum.xojo.com/u/Nicholas_Loveday)\
**Post date:** [March 18, 2020, 10:09am UTC](https://forum.xojo.com/t/datetime/52245/5 "2020-03-18T10:09:07Z")

</div>

OK Thanks it works.

But I really wish the folks at Xojo/REAL would drop the “xojo.xyx…” crap, it serves no purpose and I am making my own unified classes and function definitions to eliminate the need for this across both iOS and OSX/Windows desktop apps so that I can actually build apps that re-use the same high-level code CROSS PLATFORM.  
Ditto the trig functions which likewise are a mess.

Doubtless I’ll have to deal with the co-called API 2.0 when that comes out, to make that cross platform too.

Anyway here is an example that does compile for iOS:

// Julian date from current date, time and timezone offset from GMT - including daylight saving.  
// Uses Jan Meeus’ method, see for example [https://quasar.as.utexas.edu/BillInfo/JulianDatesG.html](https://quasar.as.utexas.edu/BillInfo/JulianDatesG.html)  
// It is also the USNO Ephemeris method.

Dim A, B, C, E, F as Integer  
Dim jd as Double  
Var d As Date = Xojo.Core.Date.Now

A=d.year/100  
B=A/4  
C=2-A+B  
E=365.25\*(d.year+4716)  
F=30.6001\*(d.Month+1)  
jd=C+d.day+E+F-1524.5

// and convert local time to UT (GMT):  
jd=jd+d.Hour/24+d.Minute/1440+(d.Second - d.Timezone.SecondsFromGMT)/86400

return jd

//FWIW it would nice if Xojo exposed JD as a property of the Date class, natively. Would make time/date calculations so much easier for those who don’t know the above.

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [March 18, 2020, 11:23am UTC](https://forum.xojo.com/t/datetime/52245/6 "2020-03-18T11:23:45Z")

</div>

Add using Xojo.core to the top of any function and you dont have to explicitly say it in that function every time.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:16pm UTC](https://forum.xojo.com/t/datetime/52245/7 "2021-04-29T16:16:38Z")

</div>


