Jump to content

Recommended Posts

I’m using this string

$oDate = strtotime($row['CompletedIT']);

$sDate = date(“d/m/y”,$oDate);

echo $sDate

 

to get the MYSQL date value stored in the table row ‘CompletedIT’.

 

The database value is 2010-07-22 but I get the echo return of 01/01/70

 

Can someone give me an idea as I want to display the date as dd/mm/yyyy

 

Thanks in advance

 

The way I do it is like:

 

$now = date('Y-m-d');

$oned = strtotime("$now +1 day");

$oned = date('d/m/Y', $oned);

 

so for your solution it would be

 

$oDate = strtotime("$row[CompletedIT]");

$sDate = date("d/m/Y, $oDate);

echo $sDate;

 

that should work theoretically.

Using

 

$oDate = strtotime($row["CompletedIT"]);

$sDate = date('d/m/y',$oDate);

echo $sDate

 

gives me the echo return of 01/01/70

 

when the date stored is 2010-07-22

 

Does the 01/01/70 indicate something like PHP can't find the recor?

 

I've been on this all day now and I think I am going round in circles.

When I use

 

$oDate = strtotime("$row[CompletedIT]");

$sDate = date("'d/m/y' $oDate");

echo $sDate

 

I just get todays date displayed

 

If I just use

 

echo $rows["CompletedIT"];

 

I get the date value from the DB 2010-07-22

 

 

$rows["CompletedIT"];  is not the same as $row[CompletedIT]

 

What is your actual code that fetches the result from the query?

 

You might want to reread the reply that Pikachu2000 made because using the mysql DATE_FORMAT() function directly in your query is both simpler and at least 8x faster than trying to do this using php code.

If you were developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON, php would help you find things like variable names that are different than what you are actually using because they would show up as undefined variable errors due to the name mismatch. You will save a ton of time.

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.