![]() |
How do I format a date like this?
Hi, folks:
I have a date like this in my SQL database: 1105083432 I need it in this format for my RSS feed: Sat, 07 Sep 2002 00:00:01 GMT I don't know a whole lot about Perl, but when it comes to formatting dates, I just wanna roll over and die. I've trying googling Perl date formatting in all kinda ways, but I can't find anything that comes remotely close to anything I can use, and my eyes have glazed over and my brain is now all mushy. It doesn't help that I don't know what terminology to use to google what it is I'm trying to find! (I don't know what to call that date format!) I would be *ever* so grateful for a clue before I rip all my hair out! Thanks! |
You may want to toy around with localtime() :)
|
Don't know much about Perl but from the looks of it I would imagine that what the database is storing is Unix timestamps. So like Wizard1988 suggested there's probably a function which lets you format unix timestamps into a certain type of string.
|
grimmy:
Quote:
If anyone else has any further ideas while I hammer away at this, I'd sure like to hear 'em! Thanks for getting me this far, folks! |
Oh, wait: I'm a big, fat Der!-head. I'm sposta be able to parse the various parts of the date out using gmtime()! I need to whack myself in the head with a hammer to reboot my brain. I think I just wored myself out today. Time to eat dinner and watch some TV, maybe look at it again tomorrow when I'm fresh and I can think better. Thanks, men! This oughtta do the trick. I appreciate it!
|
I would suggest the following:
use POSIX qw(strftime); my $date_string = strftime "%a, %e %b %Y %H:%M:%S %Z", $TIMESTAMP; or something to that nature. see: http://www.cppreference.com/stddate/strftime.html cheers. Steven |
... substitute %d for %e, to get double-digit Day-Of-Month ;)
(my bad) |
| All times are GMT -5. The time now is 4:43 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC