. NET and JS time date format conversion Problem Contrast analysis _ practical skills

Source: Internet
Author: User
Tags time and date

The example of this paper is analyzed. NET and JS time date format conversion problem. Share to everyone for your reference, specific as follows:

The 1415349957524 integers in JS actually represent the number of milliseconds between 1970.1.1 00:00:00 to today's point in time. And in. NET, we can use the Ticks property to get the number of milliseconds between 0001.1.1 00:00:00 to today's point in time.

The specific code implementation looks like this:

Js:

Get the number of milliseconds from 1970.1.1 00:00:00 to today
var mildate = + (new Date);

. Net:

Get the number of milliseconds from 1970.1.1 00:00:00 to today
var datestage = new DateTime (1970, 1, 1);
var datenow = DateTime.Now.ToUniversalTime ();
var datenowts = new TimeSpan (datenow.ticks-datestage.ticks);
var datemil = (long) datenowts.totalmilliseconds;

PS: For time and date show interested friends can also refer to the site online tools:

Unix timestamp (timestamp) conversion tool:
Http://tools.jb51.net/code/unixtime

Online Worldwide Time query:
Http://tools.jb51.net/zhuanhuanqi/worldtime

Online Perpetual calendar:
Http://tools.jb51.net/bianmin/wannianli

Web calendar:
Http://tools.jb51.net/bianmin/webwannianli

More interested readers of asp.net related content can view the site topics: "asp.net operation JSON tips summary", "asp.net string operation tips Summary", "ASP.net Operation XML Skills summary", "asp.net file Operation skills Summary", " asp.net Ajax Skills Summary topic and the "ASP.net cache operation skills Summary."

I hope this article will help you to ASP.net program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.