User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,191 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 423 | Replies: 4
Reply
Join Date: Jan 2008
Posts: 17
Reputation: Morty222 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Morty222 Morty222 is offline Offline
Newbie Poster

Help Time Stamp Help

  #1  
Mar 5th, 2008
I am using current_timestamp and it works great but when I output the data onto a php page it looks like this:

2008-03-05 18:05:44

Anyone know how I can make it look like this?

03-05-2008 18:05:44
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 9
Reputation: fert is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
fert's Avatar
fert fert is offline Offline
Newbie Poster

Re: Time Stamp Help

  #2  
Mar 5th, 2008
Use the date() function: http://php.net/date

  1. $time = time();
  2. $date = date('d-m-L H:i:s' , $time);
  3.  
  4. echo $date; // 03-05-2008 18:05:44
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: Time Stamp Help

  #3  
Mar 5th, 2008
Here,I made a function just for you using explode function:

  1. //$var is your timestamp...
  2. function x($var)
  3. {
  4. list($date,$time)=explode(" ", $var);
  5. list($year,$month,$day)=explode("-",$date);
  6. $newdate=$month."-".$day."-".$year." ".$time;
  7. return $newdate;
  8. }

Enjoy!!!
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation: johnsquibb is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 14
johnsquibb's Avatar
johnsquibb johnsquibb is offline Offline
Junior Poster in Training

Re: Time Stamp Help

  #4  
Mar 5th, 2008
  1. <?php
  2.  
  3. //old time
  4. $old_time = '2008-03-05 18:05:44';
  5.  
  6. //convert to UNIX timestamp
  7. $timestamp = strtotime($old_time);
  8.  
  9. //fetch new format
  10. $new_time = date('m-d-Y H:i:s' , $timestamp);
  11.  
  12. //output new time
  13. echo $new_time;
  14. ?>
The End
Reply With Quote  
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation: johnsquibb is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 14
johnsquibb's Avatar
johnsquibb johnsquibb is offline Offline
Junior Poster in Training

Re: Time Stamp Help

  #5  
Mar 5th, 2008
Originally Posted by fert View Post
Use the date() function: http://php.net/date

  1. $time = time();
  2. $date = date('d-m-L H:i:s' , $time);
  3.  
  4. echo $date; // 03-05-2008 18:05:44


'L' returns 1 if it is a leap year or 0 if it is not. Use 'Y' for 4-digit year.
The End
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC