Script Categories













Messages >>> Split String.

The substring() function allows you to pull out any combination of characters from a string. In this example, an unformated date string such as 19990422 (which represents April 22, 1999) can be split up into 1999, 04, and 22. Each of these are separate variables that you can deal with independently in your scripts!

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">      
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
var date = "19990422"; // yyyymmdd variable
year = date.substring(0,4);
month = date.substring(4,6);
day = date.substring(6,8);
datestring = month + "/" + day + "/" + year;
document.writeln("<b>"+date + " converts to " + datestring+"</b>");
//  End -->
</script>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

casino


©