0

I am inserting some data to database through my app & viewing the inserted data on app. My location can be anywhere say it is in india,Australia,uk,usa etc it means different time zones. My server is located to some other country. Every time i insert the record i am using now() function in php, which insert the latest app. Please tell is there something that i can do at my app end so that the time is always of my time zone.

Please tell how can i get the time zone at my app end?

Robi Kumar Tomar
  • 3,418
  • 3
  • 20
  • 27
TechChain
  • 8,404
  • 29
  • 103
  • 228

2 Answers2

0

You can convert the time according to your predefined time zone in the application and send this time to the server as mentioned in this answer so that you wont bother to think about the time settings of the devices in which you app is installed

Community
  • 1
  • 1
fatihk
  • 7,789
  • 1
  • 26
  • 48
0

The timestamp stored in your app is in UTC time( GMT (00:00)). You need to convert time into particular county timezone using time offset.

e.g. for india it is GMT+5:30;

So, when you manipulating time for india you need do like.

  $time = timestamp + (5.5 *60*60);

Now you convert your derived timestamp into date format to get perfect time according to timezone.

sandeepsure
  • 1,113
  • 1
  • 10
  • 17