C # does not have the same time () timestamp function as PHP, but DateTime. Now. Ticks is used to calculate the time difference.
The value of this attribute is the number represented at an interval of January 1, 0001 milliseconds since midnight, January 1, 100.
In dotnet, DateTime. Now. Ticks can be used to obtain the exact time, measured in 10 ^-7 s.
After experiments, we found that
Long a = (DateTime. Now. Ticks-aa.Ticks)/10000000-8*60*60;
TbxUrl. Text = a. ToString ();
It takes 8*60*60 to get the same value as the time () function.
What's the problem? It is the difference between eight time zones.
DateTime aa = new DateTime (1970, 1, 1 );
MessageBox. Show ("1970" + aa. Ticks. ToString () + "now" + DateTime. Now. Ticks. ToString ());
Long a = (DateTime. Now. Ticks-aa.Ticks)/10000000-8*60*60;
TbxUrl. Text = a. ToString ();
At the same time, we found that DataTime in c # has an attribute! DateTime. UtcNow has considered the time zone issue.
OK ~ Use the following code.
DateTime timeStamp = new DateTime (, 1, 1); // obtain the timeStamp of January 1 ,.
Long a = (DateTime. UtcNow. Ticks-timeStamp.Ticks)/10000000; // note that there is a time zone problem here, it will take 8 hours to use now