StickBoy
04-22-2003, 08:09 AM
When using lastModified, the display is, for instance:
04/22/2003 01:02:35
I would like to know what I can add to make it display the above as:
April 22, 2003 1:02AM
Actually, I would prefer to leave the time out of it altogether, but if that's not possible, then this will do.
I'm almost certain this is easy to do, but I don't know how :(
tamago
04-22-2003, 11:36 AM
Try this:
LMfulldate = new Date(document.lastModified)
LMDay = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][LMfulldate.getDay()]
LMDate = LMfulldate.getDate()
LMMonth = ['January','February','March','April','May','June','July','August','September','October','November',' December'][LMfulldate.getMonth()]
LMYear = LMfulldate.getFullYear()
document.write(LMDay + ', ' + LMDate + ' ' + LMMonth + ' ' + LMYear)Alternatively, you could write exactly the same thing using far more condensed code:LMfulldate = new Date(document.lastModified)
document.write(['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][LMfulldate.getDay()] + ', ' + LMfulldate.getDate() + ' ' + ['January','February','March','April','May','June','July','August','September','October','November',' December'][LMfulldate.getMonth()] + ' ' + LMfulldate.getFullYear())In case you're wondering what that is, you can make an array using this syntax:['item1','item2']So, ['item1','item2','item3'][1] would return 'item2'. This is how the line "['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][LMfulldate.getDay()]" works -- LMfulldate.getDay() returns 0 - 6 depending on the day of the week, so the whole thing picks out the first to seventh item from the array.
Hope this helps :o)
brothercake
04-22-2003, 12:58 PM
You could have a look at this (http://www.brothercake.com/scripts/updated.php) - it'll show you a number of ways of formatting the last modified data
StickBoy
04-23-2003, 12:03 AM
tamago: Thanks, that is exactly what I needed, and it works beautifully! :thumbsup:
brothercake: I love your fancy scripts, but tamago's simple one was shorter. I have, however, bookmarked your site in case I wanna get fancy in the future. Thanks!
tamago
04-23-2003, 12:36 AM
Just wondering, did you realise that Brothercake's page (http://www.brothercake.com/scripts/updated.php) has a tool down the bottom to shorten the script, using only the parts you need to get the result you want?
StickBoy
04-23-2003, 12:39 AM
Yup, I saw that, but I still think it's longer than yours. I could very well be wrong, but I'm gonna stick with what's working right now, thanks :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.