Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stuck PHP date() shows same day/time

Tags:

date

php

I'm currently having the strangest issue. I have the following php code which should render the current day and date but it's giving me "Mon, Dec 12, 2010" no matter what day it is.

<?php echo date('D, M n, Y'); ?>

if I run

<?php echo date(); ?>

It doesn't return anything.

I'm running PHP Version 5.2.13 via fastcgi on lighttpd (managed by Kloxo). My timezone is correctly set on the server (CentOS 5.5).

I don't know if this is a server problem or a php.ini problem so I'm posting here. Please move if necessary.

like image 355
jonkratz Avatar asked Nov 27 '25 00:11

jonkratz


2 Answers

'D, M n, Y' means "textual representation of day, short textual representation of month, numeric representation of month, year". So, yes, December is the twelfth month, hence 'n' will be 12. All throughout December. :)

http://php.net/manual/en/function.date.php

like image 158
deceze Avatar answered Nov 29 '25 15:11

deceze


$time = 1293501872;
echo date('D, M n, Y', $time);

echo date("Y.m.d H:i:s", $_SERVER['REQUEST_TIME']);

Check what date it returns. echo time() not date().

like image 36
Dejan Marjanović Avatar answered Nov 29 '25 16:11

Dejan Marjanović



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!