robert_gsfame Posted October 1, 2009 Share Posted October 1, 2009 okay this is my code..this is just some test code..please have a look $gettime=$_POST['year'].'/'.$_POST['month'].'/'.'1'; $change=date("d/m/Y",strtotime($gettime)); ---- if i use this then whatever i put the value then it will result this d/m/y eg: 1/5/1975 $apart=explode("/",$change); $apartx=$apart[1]; $aparty=$apart[2]; then if i use 1/5/1975 as an example it should result 5 and 1975 $combine=$apartx.'/'.$aparty; echo $combine; <------ and this will result 5/1975 The problem is if i put let say 2/3/1900...how come it will return 1/1970 which means that they don't get the value from what is written Please give me some advise Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted October 1, 2009 Author Share Posted October 1, 2009 [quote author=robert_gsfame link=topic=271227.msg1279861#msg1279861 The problem is if i put let say 2/3/1900...how come it will return 2/3/1900 <----wrong typed should be 1/3/1900 as i put 1 as a day how come it month and year always return to 1/1970 Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 1, 2009 Share Posted October 1, 2009 1/1970 corresponds to 0 seconds unix time. It's likely that strtotime() is failing and returning false. PHP is then casting the false to an int to make 0. The manual lists "Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC" are the valid time ranges, so your method will not work for dates as early as 1/3/1900. The reasons for this limitation are fairly technical and not really super important to understand unless you're curious, just know that you should use another method if you want to do dates very far in the future or past. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted October 1, 2009 Author Share Posted October 1, 2009 Dont really have an idea on this <?php $gettime='1900/5/1'; $change=date("d/m/Y",strtotime($gettime)); echo $change; ?> will return 01/01/1970 if i change $gettime with 1901/5/1 then it will also return 01/01/1970 but if i change to 1903/5/1 then it will return the correct result 01/05/1903 Can you help me?? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 1, 2009 Share Posted October 1, 2009 Dont really have an idea on this <?php $gettime='1900/5/1'; $change=date("d/m/Y",strtotime($gettime)); echo $change; ?> will return 01/01/1970 if i change $gettime with 1901/5/1 then it will also return 01/01/1970 but if i change to 1903/5/1 then it will return the correct result 01/05/1903 Can you help me?? I updated my post with the solution, sorry I was ambiguous in my original post Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted October 1, 2009 Author Share Posted October 1, 2009 do you mean that the range for time only from 1902 - 2038 before 1902 and after 2038 is invalid time is that what you mean?? Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 i was adding this for you you can study it for future reference.... http://uk3.php.net/strtotime <?php echo date("d/m/y h:i:s",strtotime("now")); ?> use all the below terms to add to the strtotime timestamp function... i don't think there any more written time functions to add to below list.... next day next week next month next year last week last month last year last monday last turesday last wednsday last thirsday last friday last saturday last sunday + 1 day + 1 week + 1 month + 1 year + 1 hour + 1 minute + 1 seconds next monday next turesday next wednsday next thirsday next friday next saturday next sunday Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 1, 2009 Share Posted October 1, 2009 do you mean that the range for time only from 1902 - 2038 before 1902 and after 2038 is invalid time is that what you mean?? Yes, using unix time functions such as date(), strtotime(), etc are limited to those date ranges in my post. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted October 1, 2009 Author Share Posted October 1, 2009 okay so to have future and past, i need to set my column into Variable not Time I get it so far!! Thanks for your help genericnumber1 and anyone here : : 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.