我的服务器将文件最后更新时间作为 php time() 字符串发送
我的 android 应用程序从服务器接收响应作为 php 时间戳,如 1365228375
据我所知,android 以毫秒为单位读取时间戳
我的问题是如何将 php time() 转换为 android 时间戳以及如何将转换后的时间戳转换为 android 应用程序中人类可读的?
最佳答案
使用 Java 的日历:(因为我心爱的日期已弃用) Calendar API
尝试这样的事情:
Calendar c = Calendar.getInstance();
c.setTimeInMillis(1365228375*1000);
System.out.print(c.toString()); - just to demonstrate the API has lots of info about presentation
只需将从 PHP 返回到 Android 应用程序的任何内容替换上面显示的“1365228375”即可。
干杯。
关于php - 如何将 php time() 转换为 android 时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15854911/