Does anyone know how to make a linux time stamp?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Does anyone know how to make a linux time stamp?

Post by genetix »

I currently own an site and I need to insert data into a mysql database every once and a while. The problem is I dont know how to write a time stamp. I'm going to be using control pannel 8 I think it is so I need to know what to put into the boxes.

Can anyone help me out?
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

Code: Select all

<?php
echo time();
?>
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

keep in mind that mysql timestamps aren't unix timestamps. If you are going to insert that timestamp into timestamp field it should be formatted as

Code: Select all

echo date("YmdHis");
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

unix timestamp just gives you overall one figure
131234123123 from jan1 1970

but mysql as said above gives like this
20031231173510
year month day hour minute second
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Correct. Unix Timestamp is the number of seconds since the Unix Epoch (01/01/1970).
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

I'm just wondering about the command input box. i noticed in all the control pannels I looked at they give you a very small space to type in commands. How would you write a command? Is it written like a normal webpage?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

have you ever done shell scripting?


webpages are markup languages. the scripting langs used are often just tools for displaying dynamic markup in regaurds to the web. if you haven't done shell scripting i STRONGLY suggest getting a tutorial on that beforeyou write a control panel/interface for linux.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

I have/use cpanel 8, and I really don't know what you're talking about. But it might be in the cpanel docs?

http://www.cpanel.net/docs.htm
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Hey I know you!

*waves*
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

I dont want to write a control pannel.

If you go into the cron job section of control pannel 8 you can type in the date you want a script to run and then you write in the script or command you want it to run when the time is reached.

Heres the demo:
http://cpaneldemo.cpanel.net:2082/front ... ecron.html?

I just need to know what to put in the command field. Can I put normal php?
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

So really your question is how do I use cron jobs then. Why not google some info about cronjob syntax. Cause this has nothing to do with cpanel or php.
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

I know how to set when it works and that but I'm using CPannel 8 on a Unix server and I was wondering if I could use php in the command line?
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

I'm using cpanel 8 on a Unix server too, in fact cpanel is only starting to work on Windows. I'm sorry though, you're questions keep changing and your english is too poor. I don't understand you. You can use php on the CLi if php is compiled as a CGI.
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

my question is the same its just people keep interpretting it wrong. I will make the full question in this post:

When I log into my control pannel for my website(CPannel 8) and I got to cronjobs then hit standard it shows options that must be filled in. The first option is an email address to email the results to. The third one is selection boxes where you select the time when the script should run. The last one is the one I'm having trouble with. Its a box with the title Command: I am wondering it I can put php in the command box. I'm trying to insert mysql rows into a database through a cron job. a demo of control pannel 8 is available at http://www.cpanel.net/.

To jump right to the cron job demo go here:

http://cpaneldemo.cpanel.net:2082/front ... ecron.html? username cpdemo
password cpdemo
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

AAH! Now that makes sense.

You can put php there if php is compiled as a CGI module on your server. If not, then no you can't. However you could call the mysql program to insert .sql files into databases. Probably easier that way anyway.
Post Reply