Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 4th, 2007, 11:51 PM   #1
BinkyM
Newbie
 
BinkyM's Avatar
 
Join Date: Sep 2007
Location: Manhattan
Posts: 4
Rep Power: 0 BinkyM is on a distinguished road
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!
__________________
Binky
Putting the smackdown on pop culture
BinkyM is offline   Reply With Quote
Old Sep 4th, 2007, 11:54 PM   #2
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 4 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
You may want to toy around with localtime()
__________________
JG-Webdesign
Wizard1988 is offline   Reply With Quote
Old Sep 5th, 2007, 12:10 AM   #3
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
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.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Sep 5th, 2007, 12:26 AM   #4
BinkyM
Newbie
 
BinkyM's Avatar
 
Join Date: Sep 2007
Location: Manhattan
Posts: 4
Rep Power: 0 BinkyM is on a distinguished road
grimmy:

Quote:
there's probably a function which lets you format unix timestamps into a certain type of string
Oh, of course; I just needed a pointer to what, zactly, that'd be. Thanks to the Wiz, I located gmtime(), which is pretty close (I'll end up with "Thu Oct 13 04:54:34 1994" and then I'll hafta append the "GMT" to it, then I don't know what I'll do about getting the comma after the day of the week and then reordering the date), but I'm closer to where I was, which was off in Greenland somewhere. Now I'm at least at the Canadian border, trying to convince the authorities to let me cross in. ;-)

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!
__________________
Binky
Putting the smackdown on pop culture
BinkyM is offline   Reply With Quote
Old Sep 5th, 2007, 12:34 AM   #5
BinkyM
Newbie
 
BinkyM's Avatar
 
Join Date: Sep 2007
Location: Manhattan
Posts: 4
Rep Power: 0 BinkyM is on a distinguished road
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!
__________________
Binky
Putting the smackdown on pop culture
BinkyM is offline   Reply With Quote
Old Sep 6th, 2007, 3:52 PM   #6
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
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
stevengs is offline   Reply With Quote
Old Sep 6th, 2007, 3:54 PM   #7
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
... substitute %d for %e, to get double-digit Day-Of-Month

(my bad)
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:42 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC