This topic is locked

Date and Time Problem

2/28/2008 6:42:01 AM
PHPRunner General questions
C
cool_jack author

Hi,
I am storing date as integer in mysql database but I have problem displaying date.Here is the code.

$date = time();

// Connect to Mysql, select the correct database, and run teh query which adds the data gathered from the form into the database

mysql_connect("localhost","root") or die(mysql_error());

mysql_select_db($db) or die(mysql_error());

$add_all = "INSERT INTO $table (date) values('$date')";

mysql_query($add_all) or die(mysql_error());


Now using php runner I went to visual editor setting and added the following code in the date field

$value = gmdate("l F d Y h:i", ($value['date'] + 5.5*3600));


Now the date it show is Thursday January 01 1970 05:30
i want that it should show the time user added some data in the database...but it showing some other time, please help

J
Jane 2/29/2008

Hi,
try to add strtotime function to your code:

$value = gmdate("l F d Y h:i", (strtotime($value['date']) + 5.5*3600));

C
cool_jack author 3/2/2008

^^thanks jane
but it didn't worked, I am totally confused because some months back I have used the same procedure and it showed the correct date but at that time I have used phprunner ver 3.5 (i think).



For testing purpose I have implemented the code in other file as

<?php

$db = 'user-comments';

$table = 'general_comments';

$date1 = time();

// Connect to Mysql, select the correct database, and run query which adds the data gathered from the form into the database

mysql_connect("localhost","root") or die(mysql_error());

mysql_select_db($db) or die(mysql_error());

$add_all = "INSERT INTO $table (date) values('$date1')";

mysql_query($add_all) or die(mysql_error());

$result = mysql_query("SELECT date From $table") or die(mysql_error());

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

$date = gmdate("l F d Y h:i", ($row['date'] + 5.5*3600));

}

echo("$date");

?>


OutPut: Sunday March 02 2008 11:38


This particular code is showing the correct time and same thing is there in commonfunctions.php file

function CustomExpression($value,$data,$field,$table="")

{

global $strTableName;

if(!$table)

$table=$strTableName;

if($table=="general_comments" && $field=="date")

{

$value = gmdate("l F d Y h:i", ($value['date']) + 5.5*3600));

}

return $value;

}


Output: Thursday January 01 1970 05:30
but still it is not showing the correct date...I really don't know the reason...why is it happening..??

J
Jane 3/3/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.