Javascript Substring

Like this blog? Consider exploring one of our sponsored banner ads...

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.

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)

About this entry