Solved

date conversion to full date

Posted on 2009-05-08
4
253 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 250 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 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

717 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