?
Solved

date conversion to full date

Posted on 2009-05-08
4
Medium Priority
?
259 Views
Last Modified: 2012-06-27
I have retrieved a date from my mysql database into a javascript variable and I am showing this javascript variable on a certificate. I am in UK so I want to present it day month year. So the date I return at the bottom for say 24th march 2009 is

24-03-2009.

However I want to display it as 24 March 2009.

Could anybody help me with that. This is purely for display purposes. Obviously I want this format for any date I return. Below is the mysql statement I ran from my php file to return the date.

Thanks.
$query = "SELECT passed, date_format(passdate,'%d-%m-%Y') as passdate FROM courses WHERE userref='$userref' and courseID='$courseID'";
$res2 = mysql_query($query) or fail("Failed getting passed from database");

Open in new window

0
Comment
Question by:RupertA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
ycTIN earned 1000 total points
ID: 24335908
don't change the database date format

"SELECT passed, passdate FROM courses WHERE userref='$userref' and courseID='$courseID'";

<?php
echo date("d F Y", strtotime('24-03-2009'));
?>

Open in new window

0
 
LVL 7

Expert Comment

by:ycTIN
ID: 24335923
0
 

Author Comment

by:RupertA
ID: 24336961
not sure if I can use strtotime as  my variable is not necessariy 24-03-2009. It may be any date.

thanks.
0
 
LVL 17

Assisted Solution

by:nplib
nplib earned 1000 total points
ID: 24338581
strtotime() is very good at guessing the correct date

echo strtotime('24-03-2009');
echo strtotime('March 3, 2009');
echo strtotime('03/24/2009');

will all produce the same result.

best think is to try and limit the way the user can enter the date.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question