Jump to content

Need Helps With date post


robert_gsfame

Recommended Posts

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.