time() not working in PHP

echo time(); gives me timestamp 1293645728 which is a timestamp of Wed Dec 31 19:00:00 EST 1969 instead of current timestamp.

In my php.ini date.timezone="US/Eastern".I am using windows and thextension=php_timezonedb.dll , I have restarted apache several times .

Any help is appreciated.


instead of

date("D M j G:i:s T Y", strtotime(time()));

just write:

date("D M j G:i:s T Y");

This is my date function .date("D M j G:i:s T Y", strtotime(time()));

strtotime is giving you incorrect results because a UNIX timestamp is an int not a string. That's OK, though, because date takes an int, not a string:

date("D M j G:i:s T Y", time());

Edit: In fact, this is redundant as date defaults its second argument to the value of time():

date("D M j G:i:s T Y");

A timestamp of 1293645728 is in fact Wed, 29 Dec 2010 18:02:08. As such, I suspect there's something wrong elsewhere. (i.e.: It's not PHP.)

For example:

   echo date('r', 1293645728);

0 is 1970 (beginning of unix epoch), 1293645728 is far from 0. Your timestamp returns 12 / 29 / 10 @ 12:02:08pm

echo date("d.m.Y H:i:s", time());

What does it return?

It looks to me like you converted the timestamp wrong, as Wolfram alpha gave me the conversion that you seem to be looking for: 6:02:08 pm UTC | Wednesday, December 29, 2010

Did you do the conversion wrong?

Need Your Help

What if main method is inside “non public class” of java file?

java main public

I have a java file containing more than one class, out of which one is public. If main method is inside a non-public class. I can't run that java file. Why is that? and there is no compilation erro...

What's wrong with this code that it doesn't compile?

java loops for-loop compilation boolean

For some reason the true and false are considered "incompatible types". Am I only suppose to run this through a boolean method? What's wrong with it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.