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
https://forums.phpfreaks.com/topic/176140-need-helps-with-date-post/
Share on other sites

[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

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.

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

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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.