Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 18th, 2007, 12:39 AM   #1
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 439
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Question Unix Timestamps?

I'm a bit confused regarding the Unix timestamps in PHP. When I use the function time() I get a Unix timestamp. However, does this returned timestamp contain in it daylight savings and timezone offsets? Or does the number solely represent a GMT timestamp? Is it the power of the date() function that takes the timezone and dst into effect? Any suggestions on this riddle? I ask because I have a timestamp that is offset from GMT which I convert into a unix timestamp using strtotime() and I need to compare it to the current date unix timestamp to see if it has expired. However I can't compare timestamps in different timezones. So will time() and strtotime() yield Unix timestamps which are in the same timezone? Wow that's confusing.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Jul 18th, 2007, 7:20 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
A timestamp is the number of seconds elapsed since midnight, January 1, 1970, GMT. At any moment, at any place in the world (or out of the world, for that matter), that number is the same.

Have you referred to the PHP manual? For instance,
Quote:
int strtotime ( string $time [, int $now] )

The function expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or the current time if none is supplied.

This function will use the TZ environment variable (if available) to calculate the timestamp. Since PHP 5.1.0 there are easier ways to define the timezone that is used across all date/time functions. That process is explained in the date_default_timezone_get() function page.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 18th, 2007, 2:47 PM   #3
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 439
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
I did refer to the manual first and it was two things which confused me, perhaps due to lack of reading comprehension on my own part. Namely
Quote:
relative to the timestamp given in now ... This function will use the TZ environment variable (if available) to calculate the timestamp
In any case I've just decided to work on the assumption that both time() and strtotime() produce timestamps that can be compared equivalently.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Jul 25th, 2007, 8:18 PM   #4
Komodo
Hobbyist Programmer
 
Komodo's Avatar
 
Join Date: May 2005
Location: Scranton, PA
Posts: 112
Rep Power: 0 Komodo is an unknown quantity at this point
Send a message via AIM to Komodo Send a message via MSN to Komodo
I noticed that during the winter windoes says my timezone is GMT-5, and in the summer it is GMT-4. so the timezone shouldn't make a difference, although whether it does or not I haven't the slightest.
Komodo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
convert dates in Unix time format ktsirig PHP 2 Feb 11th, 2007 9:20 PM
Unix commands compatible with Windows? titaniumdecoy Bash / Shell Scripting 7 Oct 5th, 2006 8:25 AM
Lions' Commentary on UNIX 6th Edition, with source code Mad_guy Book Reviews 0 Sep 24th, 2006 8:06 PM
Best Linux or Unix Desktop? Prm753 Coder's Corner Lounge 23 Apr 8th, 2006 11:17 AM
Importing from DLL's on Unix Kaja Fumei Existing Project Development 5 Jan 9th, 2006 7:35 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC