LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-07-2010, 10:36 AM   #1
D3158
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Rep: Reputation: 0
Current date and time


Hi guys, I am using the Terminal. I would like to know how do I put the current date and time on my machine and the date from a certain URL that has .php extension into a file.

Please help!
D3158
 
Old 12-07-2010, 10:41 AM   #2
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
Quote:
Originally Posted by D3158 View Post
Hi guys, I am using the Terminal. I would like to know how do I put the current date and time on my machine and the date from a certain URL that has .php extension into a file.

Please help!
D3158
I don't really understand what you're trying to do but:
Code:
08:38:58 /etc/privoxy $ > echo $(date +%m%d%y)
120710
08:39:09 /etc/privoxy $ >
provids mmddyy. See man date for the many options of getting the date and time.

Afterthought: Are you trying to get the date/time from within a PHP file?
 
Old 12-07-2010, 10:49 AM   #3
D3158
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by barriehie View Post
I don't really understand what you're trying to do but:
Code:
08:38:58 /etc/privoxy $ > echo $(date +%m%d%y)
120710
08:39:09 /etc/privoxy $ >
provids mmddyy. See man date for the many options of getting the date and time.

Afterthought: Are you trying to get the date/time from within a PHP file?
Yes, your afterthought is bang on. Put the current date and time on your machine and the date from the example URL: http://url.ca/date.php into a file.
 
Old 12-07-2010, 12:24 PM   #4
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
Quote:
Originally Posted by D3158 View Post
Yes, your afterthought is bang on. Put the current date and time on your machine and the date from the example URL: http://url.ca/date.php into a file.
Didn't see any date/time info at that link. Since php provides about as many ways to slice/dice the date/time as bash does it might be best to have a look at the php manual for the date function. http://us.php.net/manual/en/function.date.php I've used this to datestamp sessions:
Code:
$month = date('m');
$day = date('d');
$year = date('Y');
$datestamp = $month."-".$day."-".$year;
This is pulled from the php manual:
Code:
Time  	---  	---
a 	Lowercase Ante meridiem and Post meridiem 	am or pm
A 	Uppercase Ante meridiem and Post meridiem 	AM or PM
B 	Swatch Internet time 	000 through 999
g 	12-hour format of an hour without leading zeros 	1 through 12
G 	24-hour format of an hour without leading zeros 	0 through 23
h 	12-hour format of an hour with leading zeros 	01 through 12
H 	24-hour format of an hour with leading zeros 	00 through 23
i 	Minutes with leading zeros 	00 to 59
s 	Seconds, with leading zeros 	00 through 59
u 	Microseconds (added in PHP 5.2.2) 	Example: 654321
So:
Code:
$hours = date('H'); // Hours with leading zero's.
$minutes = date('i'); // Minutes with leading zero's.
Once again, I suggest looking at the php manual link. Lot's of options.!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: formatting current date & time as: 2006-04-12 13:47:36 and substract 15 minutes NaCo Linux - Software 4 11-13-2008 07:31 PM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
Setting environment variable to current date/time nafan Programming 1 08-23-2004 09:04 PM
Appending current date and time to a file frankietomatoes Linux - General 5 11-18-2002 02:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration