![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2007
Location: Manhattan
Posts: 4
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#2 |
|
Professional Programmer
|
You may want to toy around with localtime()
![]()
__________________
JG-Webdesign |
|
|
|
|
|
#3 |
|
King of Portal
|
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.
__________________
You are here to serve the board. So post well... and live. SPAMMING SPEED! GrimBB |
|
|
|
|
|
#4 | |
|
Newbie
Join Date: Sep 2007
Location: Manhattan
Posts: 4
Rep Power: 0
![]() |
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! |
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Sep 2007
Location: Manhattan
Posts: 4
Rep Power: 0
![]() |
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!
|
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 3
![]() |
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
__________________
-Steven "Is this a piece of your brain?" - Basil Fawlty |
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 3
![]() |
... substitute %d for %e, to get double-digit Day-Of-Month
![]() (my bad)
__________________
-Steven "Is this a piece of your brain?" - Basil Fawlty |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Date Routine | tbohon | Perl | 2 | Jan 15th, 2007 11:14 AM |
| converting string to float | beginnerCCC | C | 22 | Oct 2nd, 2006 11:59 PM |
| date format | guess | PHP | 2 | Mar 10th, 2006 5:40 PM |
| Php Postgresql Class | Pizentios | Show Off Your Open Source Projects | 15 | Jun 28th, 2005 9:55 AM |
| change the empty function from the old format to the new format | powah | Sed and Awk | 0 | Jun 23rd, 2005 11:10 AM |