Solved

date conversion to full date

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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