How does JavaScript convert the DateTime field type in the database ?, Convert database datetime

Source: Internet
Author: User

How does JavaScript convert the DateTime field type in the database ?, Convert database datetime

Javascript is a literal-literal scripting language. It is a dynamic, weak, prototype-based language with built-in support types. Its Interpreter, called the JavaScript engine, is a part of the browser and is widely used in the script language of the client. It was first used on html (an application under the standard General Markup Language) web pages, it is used to add dynamic functions to HTML webpages.

In 1995, BrendanEich of Netscape was first designed and implemented on the browser of Netscape Navigator. Because Netscape works with Sun, the management of Netscape wants it to look like java, so it is named JavaScript. But in fact, its syntax style is close to Self and Scheme.

To gain technical advantages, Microsoft launched JScript and CEnvi launched ScriptEase, which can run on the same browser as JavaScript. To unify the specifications, JavaScript is also known as ECMAScript because it is compatible with the ECMA standard.

First, let's take a brief look at the data types in Javascript. Javascript has data types in string, number, Boolean, array, object, Null, and Undefiend6. At the same time, JavaScript has dynamic types. That is to say, the same variables can be of different types:

Next we will introduce several types of conversion for Data Types in JavaScript;

1. conversion functions

JavaScript provides two conversion functions: parseInt () and parseFloat. Here, parseInt () converts the value to an integer, and parseFloat () converts the value to a floating point. The parameters of these two functions can only be of the String type.

Before determining whether a string is a numeric value, parseInt () and parseFloat () will carefully analyze the string. The parseInt () method first checks the character at the position 0 to determine whether it is a valid number. If not, the method returns NaN and does not continue to perform other operations. However, if the character is a valid number, this method will view the characters at position 1 and perform the same test. This process continues until a non-valid number is found. At this time, parseInt () converts the string before this character into a number.

The parseInt () method also has the base mode, which can convert binary, octal, hexadecimal, or any other hexadecimal string to an integer. The base is specified by the second parameter of the parseInt () method.

2. Forced type conversion

In JavaScript, we can also use forced type conversion to process different types of variables.

① Boolean (value) -- converts a given value to a Boolean value.

② Number (value) -- converts a given value to a Number

③ String (value) -- converts a given value to a String

After reading the above content, do you know how JavaScript converts the DateTime field type in the database?

In the program, the data of the Date and time type read from the database is generally in this format: "/Date (139832079 + 0800 )/"

We want to convert it to this form: '2017-12'

The following js functions are available:

If you need the format of long date and long time:

Conclusion:

Today, I will give you a brief introduction to the conversion of data types and Data Types in JavaScript For your reference only. There is still a lot of knowledge in JavaScript that we need to learn, and we will continue to study it!

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.