Converting Date to another form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Converting Date to another form

Post by dream2rule »

I have a date field in the form in the format YYYY-MM-DD (1991-01-01)

I want to convert this date field in the Format of (F j Y) ==> Jan 01 1991

but when i try to do the above its converting the current system date but not taking the date which has been entered using the form.

What might be the issue?

Regards,
Dream2rule
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2.1. When asking a question, be as specific as you can be, provide the relevant code and any other information that is helpful in a concise and coherent manner. If you are not sure how to do that, read these guidelines.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

post your code
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Post by dream2rule »

Code: Select all

$str = '01-01-1991';

$timestamp = strtotime($str);

$date = date('F j Y', $timestamp);
Got the solution thanks...!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If this information is coming from a database, which it appears to be, use the database's date functions to convert it.
Post Reply