redarrow Posted August 15, 2006 Share Posted August 15, 2006 if i add the timestamp to the database and put it under date but a time stampwhat command do you use to get it in the database as the time stamp.example$date=date("y-m-d");$date_know=strtotime($date);echo $date; Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 15, 2006 Share Posted August 15, 2006 If the database field definition is DATE use dateIf the database field definition is DATETIME use time stampNot sure if that actually answers the question ... ? Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 say you want to enter in the database the date for today but you want the database to have it in the format of a time stamp how cheers. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 15, 2006 Share Posted August 15, 2006 Do you mean a unix timestamp? A unix timestamp returns the number of secounds since Jan 1st 1970. if you want to convert a date into a unix timestamp use strtotime function:[code=php:0]$date = "25-12-2006";// conver the date above into unix timestamp// which is 1167004800$timestamp = strtotime($date);// convert it back into a dateecho date("d - m - y", $timestamp);[/code]or use the time() function to get the unix timestamp of now.I use INT as the data type for storing timestamps. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 thanks wildteens will do tell you how i go cheers mate. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 i am so confused when i turn the timestamp back i get 01-01-70 should be 15-08-06what am i doing wrong please cheers.[code]<?php$date=date("d-m-y");//echo $date;//15-08-06$date_know=strtotime($date);//echo $date_know;//1438815600 is the time stamp.$timestamp_result=date("d-m-y",$dateknow);echo $timestamp_result;//i get this why? 01-01-70?>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 15, 2006 Share Posted August 15, 2006 $timestamp_result=date("d-m-y",$dateknow);should be:$timestamp_result=date("d-m-y",$date_know); Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 didnt see that cheers what an ?????thank you .one last quistion what does int stand for ? Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 integer range of long numbers i think. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 why dosent windows like the code got this errorWarning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 pleae tell me cheers.[code]<?php//time stamp for one month foward.$timestamp_one_month_foward="262974383";//time currently plus time stamp for 1 month.$date=("d-m-y")+$timestamp_one_month_foward;// convert date into the unix timestamp$date_timestamp=strtotime($date);// get current date what should be 1 month foward. $result=date("d-m-y",$date_timestamp);echo $result;?>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 15, 2006 Share Posted August 15, 2006 From the date() page of the php manual ... the answer is that Jan 1/70 is the beginning of time.[quote]Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)[/quote]As long as Barand and me (and a few others) stay away, that won't matter :o Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 15, 2006 Author Share Posted August 15, 2006 lol that funnydoes this look ok and correct it dispalys correctl but is it a proper programming wayplease and cheers. [code]<?php// 1 month in front of current date.$m=date("m")+1;// current date.$date=date("d-$m-y");// current date in a time stamp$date_timestamp=strtotime($date);echo "<br>This is the time stamp one month foward:$date_timestamp<br>";$result=date("d-m-y",$date_timestamp);echo "<br>This is the readable result:$result<br>";?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.