I need some help bad, please help!
Moderator: General Moderators
-
teamparadox
- Forum Newbie
- Posts: 1
- Joined: Fri Sep 06, 2002 10:25 pm
I need some help bad, please help!
My website needs this new script to go live, but the following code
$date = $row["date"];
$ndate = explode("/",$date);
$ndate = mktime(0,0,0,$ndate[0],$ndate[1],$ndate[2]);
$date = strftime("%B %d, %Y",$ndate);
print $date;
Is saying the date is October 6th 2003, but the info in the database says sept 6th 2002, something is wrong with my code, im new at this and i cant figure it out, can anyone help?
$date = $row["date"];
$ndate = explode("/",$date);
$ndate = mktime(0,0,0,$ndate[0],$ndate[1],$ndate[2]);
$date = strftime("%B %d, %Y",$ndate);
print $date;
Is saying the date is October 6th 2003, but the info in the database says sept 6th 2002, something is wrong with my code, im new at this and i cant figure it out, can anyone help?
-
teamparadox2k
- Forum Newbie
- Posts: 3
- Joined: Sat Sep 07, 2002 12:14 am
- Location: none
- Contact:
nope
the date string the code is handling is from MySQL, its set when the user posts, i checked that and its all correct, its just somewhere in that codeitself thats wrong
Following check should before proceed :
1. Order of parameter in mktime(hr,min,sec,mnt,day,yr)
2. Array [$ndate] index and values
3. When inserting the some time input we provide is incorrect
When I work on the code with my database which stored the date in
I gets strange result with
1. No value in the array for index 1,2
2. mktime output give -1
regards,
Sachin
1. Order of parameter in mktime(hr,min,sec,mnt,day,yr)
2. Array [$ndate] index and values
3. When inserting the some time input we provide is incorrect
When I work on the code with my database which stored the date in
Column : name - expirydate
type - datetime
Code: Select all
$date = $rowsї0];
$ndate = explode("/",$date);
echo $ndateї0]."<br>"; //output => Complete Date
echo $ndateї1]."<br>"; //output => Nothing
echo $ndateї2]."<br>"; // output => Nothing
$ndate = mktime(0,0,0,$ndateї0],$ndateї1],$ndateї2]);
echo "-".$ndate."<br>"; // output => -1
$date = strftime("%B %d, %Y",$ndate);
echo $date;//output => NothingI gets strange result with
1. No value in the array for index 1,2
2. mktime output give -1
regards,
Sachin
-
teamparadox2k
- Forum Newbie
- Posts: 3
- Joined: Sat Sep 07, 2002 12:14 am
- Location: none
- Contact:
humph
ok if the format the batabase is saving in is 22:26 09/06/02 then what is wrong with the code?
-
teamparadox2k
- Forum Newbie
- Posts: 3
- Joined: Sat Sep 07, 2002 12:14 am
- Location: none
- Contact:
.
because i do not yet know php, my programmer has fallen off the planet and this needs to go live and i couldnt figure out the problem myself, so i turned to a php forum for help
you have a 2-digit-only year format for DATETIME??? That's a problem I would say.ok if the format the batabase is saving in is 22:26 09/06/02 then what is wrong with the code?
nevertheless I think this should do
Code: Select all
preg_match('!(\d{2})/(\d{2})/(\d{2})!', $rowї0], $ndate);
$ndate = mktime(0,0,0,$ndateї1],$ndateї2],$ndateї3]);
$date = strftime("%B %d, %Y",$ndate);
echo $date;Can't you do just this?
Code: Select all
<?php
$ndateї3] = "20"+$ndate;
$ndate = mktime(0,0,0,$ndateї1],$ndateї2],$ndateї3]);
$date = strftime("%B %d, %Y",$ndate);
echo $date;
?>