Solved

date conversion to full date

Posted on 2009-05-08
4
240 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
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
ycTIN earned 250 total points
Comment Utility
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
Comment Utility
0
 

Author Comment

by:RupertA
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now