开发者

Convert Android SMS table date to meaningful DateTime format using other than Java

开发者 https://www.devze.com 2023-02-24 05:28 出处:网络
I\'m wondering how to convert Sms table date value e.g. 1293457709636 (miliseconds) to meaningful Date time value using Microsoft platforms, not Java.

I'm wondering how to convert Sms table date value e.g. 1293457709636 (miliseconds) to meaningful Date time value using Microsoft platforms, not Java.

I've just made a backup of my SMS messages from a HTC phone. I exported as XML file and for the date i have something like this: 1301061775000. I've got a solution from this post: Android - get date time from SMS timestamp in miliseconds but unfortunately开发者_C百科 require to have installed and also knowledge of Java which i'm not.

It is possible to convert from this format to something like mm/dd/yyyy HH:ii:ss using Microsoft (don't shoot me!) tools/ide/languages (.NET, C#, VB) or PHP because I have to automate somehow this process since there are more than 600 messages.


The android datetime is milli-secs since Jan 1, 1970. I use the following exention method to convert it to a .NET DateTimeOffset.

public static DateTimeOffset Epoch = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);

...

public static DateTimeOffset FromMilliSecsSinceEpoch(this long millSecs)
{
    return Epoch + TimeSpan.FromMilliseconds(millSecs);
}


Just divide your date by 1000. For example:

$androidDate = '1237653891234';

$MyDate = $androidDate/1000;

$NewDate = date('D/M/Y-h:i:s A, $MyDate);

will output DD/MM/YYYY-00:00:00 AM

0

精彩评论

暂无评论...
验证码 换一张
取 消