简体   繁体   English

从Android应用程序向php发送日期时,会出现1天的差异

[英]Getting difference of 1 day when date is sent from android application to php

I am developing the android application in which persons can enter leave application. 我正在开发人们可以进入请假应用程序的android应用程序。 Here users select the date from the Android Calendar and from this selected Date Epoch value is sent to php page on converting the epoch readable date format i get a difference of 1 Day. 在这里,用户可以从Android日历中选择日期,然后从此选定的Date Epoch值发送到转换Epoch可读日期格式的php页面,我得到1天的差值。

As on php page i calculate the to date for the leave using the number of leave and from date but here im getting the wrong value as from date on the php differs from the selected date on the android application. 如在php页面上,我使用请假和开始日期的数量计算请假的日期,但是在这里,我从php上的开始日期获取的值与在Android应用程序中选择的日期不同。

Kindly help.. 请帮助。

It turned out to be a timezone issue. 原来是时区问题。 The dates get a default timezone upon creation. 日期在创建时会获得默认时区。 But it makes a difference between 0 and 1 day if there different timezones involved. 但是,如果涉及不同的时区,则在0天和1天之间会有所不同。 Especially if you create a date, transfer the timestamp (as long int) and create another date from it. 特别是如果您创建日期,请传输时间戳记(为long int)并从中创建另一个日期。

For more details see the comments to the question :-) 有关更多详细信息,请参见问题注释:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM