hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Date convirsion with php, is it possible ?
Reply

Forum Jump

Date convirsion with php, is it possible ?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old
Newbie
 
Join Date: Aug 2002
Posts: 7

Date convirsion with php, is it possible ?


Hi, I've just started php and am trying to convert a day number for example day 254 of year 2002 to format day of month of year. I have worked out how to make a program that soes this but it would be quite long and a pain to do, is there any function in PHP that would allow you to do this easily?



Sponsored Links
  #2  
Old
Web Hosting Master
 
Join Date: Nov 2001
Posts: 857
If this isn't what you are looking for let me know...

The following code outputs 09-11-02
PHP Code:
<?
echo date ("m-d-y"mktime (0,0,0,1,254,2002));
?>
If you would rather it output it in 09/11/02 format change the m-d-y to m/d/y

Other than that I am pretty sure I understood you.

Above the 1 is the month of January.
The 245 is the days from day 0 of that month. The 2002 is the day.

So basically mktime() returns the UNIX time stamp for 245 days after Jan 0, 2002. Then the date function converts it to m/d/y format...

EDIT:
If you would rather call a function instead of useing that format in each location you can do this.
PHP Code:
function return_date($day$year)
{
  return 
date("m/d/y"mktime (0,0,0,1,$day,$year));

Then you can call it like:
PHP Code:
$my_date return_date('254''2002');
echo 
$my_date
Regards,
Michael

__________________
<?
header("Location: http://www.hostevolve.com/");
?>


Last edited by michaeln; 08-23-2002 at 04:43 PM.
  #3  
Old
New Member
 
Join Date: Aug 2002
Location: Your House
Posts: 3
sounds pretty easy, you need a custom script for this.

Sponsored Links
  #4  
Old
Newbie
 
Join Date: Aug 2002
Posts: 7
Thanks, exactly what I was looking for

  #5  
Old
Junior Guru
 
Join Date: Aug 2002
Location: Plymouth
Posts: 212
Good you made a function. Apply it in a global file so that it can be called from any module.

  #6  
Old
Newbie
 
Join Date: Aug 2002
Posts: 7
Sorry what global file?

  #7  
Old
Web Hosting Master
 
Join Date: Nov 2001
Posts: 857
I think he simply means put it in a file named whatever you wish, lets say global.php.

Then at the top of each of the scripts in your site you put:
require("global.php");
if the file is in the same directory as the global file or
require("/path/to/global/file/global.php");
if the file is not in the same directory.

After that any variables or functions in global.php can now be used in the file you put the require statement in....

__________________
<?
header("Location: http://www.hostevolve.com/");
?>

  #8  
Old
Newbie
 
Join Date: Aug 2002
Posts: 7
Oh thanks Now I understand, actually I only needed it once in the script so this wont be necessary

Reply

Related posts from TheWhir.com
Title Type Date Posted
Labour Calls for Greater Accountability by British Intelligence Agencies in Speech Addressing Cybercrime Web Hosting News 2014-03-03 11:20:48
Nominet Goes Ahead with Shorter .UK Domains Despite Negative Feedback Web Hosting News 2013-11-21 11:02:46
ServerPoint Launches New Cloud VPS Hosting Solution Web Hosting News 2013-07-12 09:20:41
Kim Dotcom Extradition Hearing to be Delayed Again Web Hosting News 2013-06-10 14:28:26
10-14-2012 Roswell, NM - The Hosting Shift Blog 2012-10-24 15:14:40


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?