UseWhen datacontractjsonserializer serializes datetime, it uses datetime. ticks to convert the Unix timestampe mode.
It should be noted that it takes only a few milliseconds. If you use PHP or other languages for parsing, You need to perform a 1000 conversion. For example:
Echo Time (); // Get it in PHPUNIX epoch time
Echo Date ( ' Y-m-d h: I: S ' , 1258698799374 / 1000 + 60 * 60 * 8 ); // Convert epoch time in PHP
Paste it by the wayUse of datacontractjsonserializer:
Code ClassProgram
{
Static Void Main ( String [] ARGs)
{
Console. writeline (tojson (datetime. parse ( " 2009-11-20 " )));
Console. writeline (tojson (datetime. Now. ticks ));
Console. readkey ();
}
Public Static String Tojson ( Object Value)
{
VaR Ser = New Datacontractjsonserializer (value. GetType ());
VaR MS. = New Memorystream ();
Ser. writeobject (MS, value );
Return Encoding. Default. getstring (Ms. toarray ());
}
}
Ref: http://www.epochconverter.com /#