Jump to content

problem with displaying correct date


raven2009

Recommended Posts

hi all i have a problem with my statements displaying the wrong date

it keeps displaying Nov 30, 1999 even though i am doing it different days

 

these are my codes

 

user statement

<?php
$getUser="select * from transactions where uid='$id' order by date desc";

$getUser=mysql_query($getUser);
$users=mysql_num_rows($getUser);

while($row=mysql_fetch_array($getUser))
{

$idDB=$row['id'];
$typeDB=$row['type'];
$transactionDB=$row['transaction'];
$amountDB=$row['amount'];
$dateDB=$row['date'];


					    list($day, $month, $year) = split("-", $dateDB);
    $dateDB = date('d M, Y', mktime(0, 0, 0, $day, $month, $year));
?>
                                      <tr>
                                        <td bordercolor="#C9D4E3" bgcolor="#5E5E5E"><div align="center"><strong><?php echo $typeDB; ?></strong></div></td>
                                        <td bordercolor="#C9D4E3" bgcolor="#5E5E5E"><div align="center"><strong><?php echo $dateDB; ?></strong></div></td>
                                        <td bordercolor="#C9D4E3" bgcolor="#5E5E5E"><div align="center"><strong><a href="statementfullview.php?tid=<?php echo $idDB; ?>

 

and the form to add statment

<?php

require_once('../config.php');

if(isset($_POST['addTransaction']) && $_POST['addTransaction']=='addTransaction')
{

$email=$_POST['email'];
$type=$_POST['type'];
$date=$_POST['date'];
$transaction=$_POST['transaction'];
$amount=$_POST['amount'];
$info=$_POST['info'];

$getUser="select id from users where email='$email'";
$getUser=mysql_query($getUser);
while($row=mysql_fetch_array($getUser))
{
$uid=$row['id'];
}

$addTransaction="insert into transactions(id,uid,type,transaction,amount,date,info) 
values('','$uid','$type','$transaction','$amount','$date','$info')";
//echo $register;
$addTransaction=mysql_query($addTransaction);

if($addTransaction)
{
?> 
<script language="javascript1.1">
alert('Transaction added successfully!');
</script> 
<?
}
else
{
?> 
<script language="javascript1.1">
alert('addTransaction not added! please try again.');
</script> 
<?
}


}

?> 

 

thanks in advance  :)

Link to comment
https://forums.phpfreaks.com/topic/157611-problem-with-displaying-correct-date/
Share on other sites

hi all i have a problem with my statements displaying the wrong date

it keeps displaying Nov 30, 1999 even though i am doing it different days

 

these are my codes

 

user statement

<?php
$getUser="select * from transactions where uid='$id' order by date desc";

$getUser=mysql_query($getUser);
$users=mysql_num_rows($getUser);

while($row=mysql_fetch_array($getUser))
{

$idDB=$row['id'];
$typeDB=$row['type'];
$transactionDB=$row['transaction'];
$amountDB=$row['amount'];
$dateDB=$row['date'];


					    list($day, $month, $year) = split("-", $dateDB);
    $dateDB = date('d M, Y', mktime(0, 0, 0, $day, $month, $year));
?>
                                      <tr>
                                        <td bordercolor="#C9D4E3" bgcolor="#5E5E5E"><div align="center"><strong><?php echo $typeDB; ?></strong></div></td>
                                        <td bordercolor="#C9D4E3" bgcolor="#5E5E5E"><div align="center"><strong><?php echo $dateDB; ?></strong></div></td>
                                        <td bordercolor="#C9D4E3" bgcolor="#5E5E5E"><div align="center"><strong><a href="statementfullview.php?tid=<?php echo $idDB; ?>

 

and the form to add statment

<?php

require_once('../config.php');

if(isset($_POST['addTransaction']) && $_POST['addTransaction']=='addTransaction')
{

$email=$_POST['email'];
$type=$_POST['type'];
$date=$_POST['date'];
$transaction=$_POST['transaction'];
$amount=$_POST['amount'];
$info=$_POST['info'];

$getUser="select id from users where email='$email'";
$getUser=mysql_query($getUser);
while($row=mysql_fetch_array($getUser))
{
$uid=$row['id'];
}

$addTransaction="insert into transactions(id,uid,type,transaction,amount,date,info) 
values('','$uid','$type','$transaction','$amount','$date','$info')";
//echo $register;
$addTransaction=mysql_query($addTransaction);

if($addTransaction)
{
?> 
<script language="javascript1.1">
alert('Transaction added successfully!');
</script> 
<?
}
else
{
?> 
<script language="javascript1.1">
alert('addTransaction not added! please try again.');
</script> 
<?
}


}

?> 

 

thanks in advance  :)

 

seems there isnt a problem with the code the date format thats the problem

im in the uk so my date is displayed dd/mm/yyyy and the database wants me to add it as yyyy/mm/dd strange! lol  ???

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.