Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Format date from value in table
Old 09-29-2010, 12:37 PM Format date from value in table
Skilled Talker

Posts: 83
Trades: 0
Hey, I am grabbing a date from a row in my table which is currently formatted as:
date("Y-m-d")
2010-09-29

So in my code I have something like this:

$row['date'];

How do I use this to rearrange the date to look like:

09-29-2010

I looked at the formatting tutorials, but they explain how to format it for the date you are currently setting into a variable.
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-29-2010, 12:46 PM Re: Format date from value in table
Justinwiz's Avatar
Skilled Talker

Posts: 58
Name: Justin
Location: /etc/httpd/logs/error_log
Trades: 0
PHP Code:
<?php
$date 
"2010-09-29";
$dArray explode("-"$date);
$newDate $dArray[1]. "-" .$dArray[2] ."-"$dArray[0];
echo 
$newDate
?>
Just replace $date with the database item.

Justinwiz is offline
Reply With Quote
View Public Profile
 
Old 09-29-2010, 12:49 PM Re: Format date from value in table
Skilled Talker

Posts: 83
Trades: 0
That did it. Thanks very much!
Smudly is offline
Reply With Quote
View Public Profile
 
Old 09-29-2010, 12:57 PM Re: Format date from value in table
Justinwiz's Avatar
Skilled Talker

Posts: 58
Name: Justin
Location: /etc/httpd/logs/error_log
Trades: 0
Quote:
Originally Posted by Smudly View Post
That did it. Thanks very much!
No problem
Justinwiz is offline
Reply With Quote
View Public Profile
 
Old 09-29-2010, 02:22 PM Re: Format date from value in table
miki86's Avatar
Extreme Talker

Posts: 185
Location: print_r($serbia);
Trades: 0
Or
PHP Code:
$epoch strtotime($row['time']); 
$time strftime("%d-%m-%Y"$epoch);
echo 
$time
miki86 is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Format date from value in table
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29912 seconds with 12 queries