....
Secondly, is there a way to parse the filename to convert it into something more legible? So 0507230004461.jpg would translate into July 23, 2005 - 12:10 AM? I would need to have the expression look at the correct set of digits and do the translation.
Okay, I'll bite
Code:
parseDateString('0507230004461.jpg');
function parseDateString(date){
var year =date.substring(0,2);
var month = date.substring(2,4);
var day = date.substring(4,6);
var hour = date.substring(6,8);
var minutes =date.substring(8,10);
var seconds = date.substring(10,12);
switch (month)
{
case "01":
month = 'January';
break;
case "02":
month = 'February';
break;
case "03":
month = 'March';
break;
case "04":
month = 'April';
break;
case "05":
month = 'May';
break;
case "06":
month = 'June';
break;
case "07":
month = 'July';
break;
case "08":
month = 'August';
break;
case "09":
month = 'September';
break;
case "10":
month = 'October';
break;
case "11":
month = 'November';
break;
case "12":
month = 'December';
break;
}
//assume 2000+ for year
year = "20" + year;
if(minutes > 0){
minuteFormat = ":" + minutes;
}else{
minuteFormat = ":00";
}
if(hour == 0){
timeFormat = "12" + minuteFormat + " AM";
}else if(hour < 12){
timeFormat = hour + minuteFormat + " AM";
}else if(hour > 12 && hour != 24){
hour = hour - 12;
timeFormat = hour + minuteFormat + " PM";
}else if(hour == 12){
timeFormat = hour + minuteFormat + " PM";
}else if(hour == 24){
timeFormat = "12" + minuteFormat + " AM";
}
return month + " " + day + ", " + year + " - " + timeFormat;
}
But, I can't for the life of me figure out how
0507230004461.jpg
would be
July 23, 2005 - 12:10 AM
instead of
July 23, 2005 - 12:04 AM