cut string in JavaScript using substr function

function cutstring(){btime = ‘HH:MM:AMPM ‘;var hh = btime.substr(0,2); var mm = btime.substr(3,2); var ampm =btime.substr(6,2);alert(hh);alert(mm);alert(ampm);} String : HH:MM:AMPM

syntex : 


var cutstr = string.substr(startIndex , Length) ; 

CODE :- 

function cutstring(){

btime = ‘HH:MM:AMPM ‘;

var hh = btime.substr(0,2);
var mm = btime.substr(3,2);
var ampm =btime.substr(6,2);
alert(hh);
alert(mm);
alert(ampm);

}

String :  HH:MM:AMPM

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s