The Javascript substring function is very similar to that of PHP. The first parameter is the start position and the second parameter is the end position. The first character in a javascript string is position 0.

第一个参数是开始位置,第二个参数是结束位置,位置是从0开始计数的。

Here is a simple example:

var birthday = ’1978-07-11′
var year = birthday.substring(0,4)
var month = birthday.substring(5,7)
var day = birthday.substring(8,10)

本文地址:http://www.yaronspace.cn/blog/index.php/archives/304


来自yaronspace.cn  本文链接:http://yaronspace.cn/blog/archives/304