Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 19th, 2001, 05:54 PM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
date and time [ php --> perl ]

php to perl [ date and time ]
Hi,
Im trying to find todays date and time in perl.. how do i do that??

I know how to do it in php.. but i dont know how to convert the php to perl

this is what i am doing in php

$date = date("m-d-y");
$time = date("g:i a T");

I want a replica of this output in perl..

any help would be great!

Reply With Quote
  #2  
Old July 19th, 2001, 06:42 PM
heygoena heygoena is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Santa Barbara, CA
Posts: 5 heygoena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to heygoena
Hopefully this will help, I'm not too great at perl myself.

---------------------------------------------------------------
#usr/bin/perl -w
use POSIX qw(strftime);
$nowdate = strftime "%m-%d-%y", localtime;
$nowtime = strftime "%I:%M %p %Z", localtime;

print "$nowdate\n";
print "$nowtime\n";
---------------------------------------------------------------

This is pretty much straight from the perl documentation which you can check out here:

http://www.perldoc.com/perl5.6/pod/localtime.html

for more info on the format strings try:

% man date

on your server.

-Jake-

Reply With Quote
  #3  
Old July 20th, 2001, 03:07 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
You could also just do:
Code:
$time = localtime;

That will give you a string with the day time and date.
__________________
- dsb -
Perl Guy

Reply With Quote
  #4  
Old July 20th, 2001, 03:59 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kunal
thanks.. problem solved

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > date and time [ php --> perl ]


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT