halliewuud
halliewuud

Reputation: 2785

timestamp in dailylight savings time

Anyone have a function to get a timestamp time() in daylight savings time? And possibly GMT+1 insted of GMT. I need it to display timestamps of comments made on my site.

Upvotes: 2

Views: 849

Answers (2)

RiaD
RiaD

Reputation: 47630

You should set your timezone to php setting. There are some ways to do it:

After that all time functions willl work in this timezone

Upvotes: 1

deceze
deceze

Reputation: 522175

Timestamps are the number of seconds elapsed since January 1st, 1970 GMT. That's a fixed number, not depending on whether you're saving daylight and independent of timezones. When you convert back to "human readable time", that's when your timezone and DST settings need to be taken into account. Set your timezone correctly or explicitly set a timezone on a DateTime object when formatting a timestamp to make this work.

Upvotes: 1

Related Questions