SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old September 9th, 2002, 09:30 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Unhappy Timestamp Prob

Ok, I have some code that is covert a given date from the format "09/09/02" into a UNIX timestamp that will be stored in a MySQL database for later retrieval. The problem, though, is that it returns the date as December 31, 1969! Could someone please help?

PHP Code:
 $created "09/09/02";
$created trim($created);                
$created explode("/",$created);
$uts mktime(000$created[0], $created[1], $created[2]);
echo 
'Unix TimeStamp: '.$uts


Thanks,
~Joe of 4Life
__________________
Check out 4Life today!

Reply With Quote
  #2  
Old September 9th, 2002, 09:58 PM
Brian Rosner Brian Rosner is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Denver, CO
Posts: 34 Brian Rosner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Brian Rosner Send a message via AIM to Brian Rosner Send a message via Yahoo to Brian Rosner
I believe that 09/09/02 should be 09/09/2002. Try that.

Reply With Quote
  #3  
Old September 9th, 2002, 10:14 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thanks, but same prob

~Joe

Reply With Quote
  #4  
Old September 9th, 2002, 10:37 PM
Brian Rosner Brian Rosner is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Denver, CO
Posts: 34 Brian Rosner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Brian Rosner Send a message via AIM to Brian Rosner Send a message via Yahoo to Brian Rosner
I tested the script on my server and it seemed to work fine

Reply With Quote
  #5  
Old September 9th, 2002, 11:06 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Works, but doesnt make proper timestamp click here....

Sorry these last couple posts are short but its really late here (12AM!)

Reply With Quote
  #6  
Old September 11th, 2002, 08:54 AM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
use the date function?

You can use symbols other than : in your date function, for example:
PHP Code:
 $myDate date("d/m/Y");
$myDate date("Y-m-d"); 

Reply With Quote
  #7  
Old September 11th, 2002, 09:36 AM
amnuts amnuts is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 1 amnuts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 47 sec
Reputation Power: 0
Hi,

What you have here works fine. I tried this out:

PHP Code:
 $created "09/09/02";
$created explode("/",trim($created));

$ts mktime(000$created[0], $created[1], $created[2]);

echo 
"timestamp = $ts\ndate = ";
echo 
date("M-d-Y"$ts), "\n"


which gave the result:

Quote:
timestamp = 1031544000
date = Sep-09-2002


Now, looking at your page you also have the timestamp as 1031544000 . This would suggest it's not the creating of the dates that's the problem, but how you're converting it to a date string.

Move the .php file you linked to to a .phps file (if your web server is setup for those), so that we can see what you've got going on and try to help out a little more.

Andy

Reply With Quote
  #8  
Old September 11th, 2002, 03:49 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thanks! I'll try that code. Also, I changed it a PHPS file so that y'all can take a look at it....

~Joe

Reply With Quote
  #9  
Old September 11th, 2002, 04:01 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Yay, it works! How can I store this in a MySQL DB? Thanks!

Reply With Quote
  #10  
Old September 11th, 2002, 05:41 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Talking

Ok, I got it!
PHP Code:
 $ts date("YmdHis"$ts); 



Btw - I love talking to myself

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Timestamp Prob


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway