|
function PB_Date(str_form) { var year,month,day,hour,min,ti; var months = {"Jan": 0, "Feb": 1, "Mar": 2, "Apr": 3, "May": 4, "Jun": 5, "Jul": 6, "Aug": 7, "Sep": 8, "Oct": 9, "Nov": 10, "Dec": 11}; var datereg1 = /(\w{3}) (\d+), (\d{4}),? (at )?(.+)/; var datereg2 = /(\d+)[.\/\-](\d+)[.\/\-](\d+) at (.+)/; var datereg3 = /(<b>Today<\/b>|Yesterday) at (.+)/i; if(str_form.match(datereg1)) { year = RegExp.$3; month = months[RegExp.$1]; day = RegExp.$2; ti = RegExp.$5; } else if(str_form.match(datereg2)) { year = RegExp.$3; if(year < 100) year += 2000; month = RegExp.$1 - 1; day = RegExp.$2; ti = RegExp.$4; } else if(str_form.match(datereg3)) { ti = RegExp.$2; var d = new Date(); if(RegExp.$1.match(/Yesterday/i)) d.setDate(d.getDate() - 1); year = d.getYear() + 1900; month = d.getMonth(); day = d.getDate(); } var timereg = /^(\d+)\d+)(am|pm)?/; if(ti.match(timereg)) { hour = parseInt(RegExp.$1); min = RegExp.$2; if(RegExp.$3 && RegExp.$3 == "pm") hour += 12; } return new Date(year, month, day, hour, min); }
|
|
|
|
Could you possibly post on where to put this code at: Main header - footer Global - header - footer Thanks flash
Last Edit: Jan 24, 2009 15:58:20 GMT by Flash
|
If you don't look at my Home I will get mad!
My Home AT Home !
|
|
|
|
This is for other coders to use in their codes, wouldn't be helpful for anyone else.
|
|
|
|
This is for other coders to use in their codes, wouldn't be helpful for anyone else. Oh Ok...thanks for the quick reply !! That is a Newbie for you. I thought that it displayed the Date you started your Forum somehwhere on the main page. Guess I will keep looking.... Thanks again flash
|
If you don't look at my Home I will get mad!
My Home AT Home !
|
|
|
|
This is for other coders to use in their codes, wouldn't be helpful for anyone else. Oh Ok...thanks for the quick reply !! That is a Newbie for you. I thought that it displayed the Date you started your Forum somehwhere on the main page. Guess I will keep looking.... Thanks again flash Nope. All the codes in the "Open Source" board (this board) are mainly intended for use by coders.
|
|
|
|
|
RegExp hates me... and I hate it... My mind blew up looking at the RegExp in #2 ... do [ .. ] basically let it match either one of the things in between eg:
[.\/\-] would match, . or / or -
basically the same as: (.|\/|\-) ?
|
|
|
|
I think . carries the "All characters" feature even inside brackets actually.... so I'm not sure why it's used there. o.O But yeah, your question on the brackets is more or less right. It's advantages are you can do this: [A-Z0-9] to get all the capital letters and numbers. That's a lot more efficient then using all the parenthesis.
Last Edit: Jan 30, 2009 0:41:06 GMT by Chris
|
|
|
|