Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

datetime - php: convert milliseconds to date

I Have a string that is equal to a date, represented as the number of milliseconds since the Unix epoch.

I am trying to output it into d-m-Y.

The string I was given was "1227643821310", and I am told that the result should be equal to 2-12-2008, but I keep getting a result of 25-11-2008

My code is as follows:

$mil = 1227643821310;
$seconds = $mil / 1000;
echo date("d-m-Y", $seconds);

Any ideas as to why this might be?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are already doing it right, 1227643821 is simply not 02-12-2008, it is indeed 25-11-2008.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...