Jump to content

[SOLVED] Format date


yukafluck

Recommended Posts

Ok I have two things that I want to do:

 

1.  I have a field in my database that is a birthdate.  It gets displayed as yyyy-mm-dd, and I want to change it to ie*january 1, 2009.  How can this be done.

 

2.  I want to be able to have that date match today's date without the year coming into effect.

 

any help or direction to a tutorial on this would be greatly appreciated.

Link to comment
Share on other sites

You might want to mention which database you're using as they all seem to have a different way when it comes to date.

At least that's my painful experience today after having to write queries that work with dates and need to work on derby, mysql and postgresql (while originally being written for sqlite).

Link to comment
Share on other sites

Maybe i should have put this into two posts, let me deal with the first, then I will post a second one for the other issue.

 

I have in my code

<?php echo $bday; ?> [code=php:0]

 

And the output on the page comes as :1968-01-02

 

but I want it to come out as: January 2, 1968.

Link to comment
Share on other sites

Ok I have two things that I want to do:

 

1.  I have a field in my database that is a birthdate.  It gets displayed as yyyy-mm-dd, and I want to change it to ie*january 1, 2009.  How can this be done.

 

2.  I want to be able to have that date match today's date without the year coming into effect.

 

any help or direction to a tutorial on this would be greatly appreciated.

 

1. Don't change, but just query to display it

SELECT  DATE_FORMAT(your_date, '%M %e, %Y') AS yourdate  FROM your_table

 

 

Link to comment
Share on other sites

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.