?
Solved

date

Posted on 2005-03-15
10
Medium Priority
?
117 Views
Last Modified: 2010-03-05
when i retrieve from database, the date is : 1104451200000

$time  = "1104451200000";  ###### this is 12:31:2004
       my @lt = localtime($time/1000);
        my ($year,$month,$day,$hour,$minute,$second) = ($lt[5]+1900,$lt[4]+1,$lt[3]+1,$lt[2],$lt[1],$lt[0]);
        print "        $month:$day:$year \n";   #### this gives me  12:20:2004...... 1 day less


i get 1 day less:

ex) if the date in databse is         12:31:2004
what i get is  12:30:2004

any ideas????

Rahul
0
Comment
Question by:shahrahulb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
10 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 750 total points
ID: 13550029
It could be where you say $lt[3]+1 . The day range will be from 1..31, not 0..30 so no need to add 1 like for month
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 750 total points
ID: 13550081
use POSIX 'strftime';
$time = 1104451200000;
print strftime "%m:%d:%Y\n", localtime($time/1000);


0
 
LVL 1

Author Comment

by:shahrahulb
ID: 13550379
i found the solution :
instaed of my @lt = localtime($time/1000);  it should be my @lt = gmtime($time/1000);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 48

Expert Comment

by:Tintin
ID: 13550496
My solution works also, and I think it is a lot neater.
0
 
LVL 84

Expert Comment

by:ozo
ID: 13550558
I agree, although it may depend on the difference beween localtime and gmtime, and exactly when you want the day to change.
0
 
LVL 1

Author Comment

by:shahrahulb
ID: 13577409
can someone please close this question as i got the solution on my own....
0
 
LVL 84

Expert Comment

by:ozo
ID: 13578020
I don't think your solution works on the last day of the month.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question