How to get Local city TimeZone and upload it to firestore as Date Or Timestamp - swift

I have a small issue dealing with dates here, I have a multiplatform app using these programing languages iOS/Swift and Android/Kotlin, in my app there is a chat messaging part that these users can use to send messages, the messages are Orderd by date in each device, there will be a date that is gotten from the devise calendar
so in Swift if I say
let date = Date() this date will be the date that's in the device
or in Kotlin
var date = Date()
those variables will give me their device dates so if the user in android sends a message and his clock was a little late his message will be on the top instead of being the last message that was sent and to make it more clear.
example
iPhone device clock is 7:44:33 hh:mm:ss & Android Device clock 7:44:55 hh:mm:ss
if the first message was sent is from the Android and then the iPhone replay to that message, messages should be ordered like this
android: Hi
iPhone: hello there
but instead of that the messages are ordered by the date and comparing the two dates that were given from the devices, the messages are ordered like this
iPhone: hello there
android: Hi
cause the iPhone calendar clock is too early, so my question is this how to get a one date for all the devices by the timezone or any other solution that is available like an international timestamp or something or an international date cause I only need these dates to order my messages nothing else.

Related

Iphone invalid date from string

I face to problem with IPhone and date.
When I run this code:
const date = new Date('2022-07-04 15:29:00');
alert(date);
But with Iphone chrome I Get following error
Invalid date
With other devices (android, windows, linux) a get correct date.
Does somebody know what kind of problem is in IPhone?
Problem is in date format. Date format has to be in ISO-8061 format.

Flutter display DateTime based on mobile device settings

I am looking for some guidance on using flutter and taking a UTC datetime from the DB and displaying that time based on mobile devices settings like locale, 24 versus 12 hour time, etc...
I have done dateformating in flutter without an issue, just hoping for some guidance to do it in this manner.
Thanks
I have found that if its for display of a UTC pulled from DB just use the DateTime.toLocal()
Then you can do the formatting on the datetime for other items.

UILocalNotification on the due date, weekly and monthly report

I am trying to work out the best way to use local notification in background to run a method to display a notification message from core data, based on due date or upcoming weekly and monthly summary report.
There are two options which I have worked out which is NSTimer and UILocalNotification.
With NSTimer i can run scheduledTimerWithTimeInterval every 24 hours in background to check core data before display local Notification to see if it is on due date, weekly or monthly report. I am not sure if this is best solutions or recommendation?
I have read other posts, they suggestion to use UILocalNotification instead. But they are only limited to 64 notifications per app. Thats ok if I use weekly and monthly which total 64 notifications but it won't work after 1 year unless user active the app also I need to display due date's on the day message as well.
I am thinking maybe after a local notification displayed then the app still in background set new next schedule local notification, but I couldn't work this one out so not sure if this is possible?
Any suggestions on this? Thank you in advance.

IPhone EventKit Discrepancy with NSDate ( Time is off by 1 hour )

I was creating an EKEvent for iCal but the time was coming out incorrectly.
When I created the NSDate and used a dateformatter to read it, the date was as I would expect it. But, when I would add the date as the startDate to the EkEvent and would add the event to the calendar it would mysteriously change to 1 hour later.
I checked through the documentation on Timezones and offsets thinking that was the root cause.
Under the iphone settings->Mail, Contacts, and Calendars->TimeZoneSupport, the phone was set to a different timezone specifically for this calendar.

Syncing data from iphone to the server Datetime question

I want sync data from iphone to the webs server. My question is how can I know which data is new? the only way I see this is by making a datafield for each record on the server and the iPhone, but how about if the Iphone user is in a different timezone or his datetime is different from the server datetime.
Store all of your dates in GMT on both the server and device. There are several methods for getting GMT easily in Objective-C. The device will determine time-zone based on location. If you need to convert to local time, you can get the date by using the NSTimeZoneClass:
[NSDate dateWithTimeIntervalSinceNow:[[NSTimeZone defaultTimeZone] secondsFromGMT]]
Check out the docs on Date and Time Programming for additional assistance.