Jump to content

[Batch] Unix time?

Amit Moryossef

SOLVED

Is there a way to get a unix timestamp in batch?

Im trying to convert a PHP code into batch, and the only thing I cant find how to do is getting a timestamp..

Link to comment
Share on other sites

Link to post
Share on other sites

Is there a way to get a unix timestamp in batch?

Im trying to convert a PHP code into batch, and the only thing I cant find how to do is getting a timestamp..

couldent you just use unix time? and why you using batch?

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

couldent you just use unix time? and why you using batch?

I did not manage using unix time, this is what I was trying to do..

I solved it anyway. (alot of calculations)

Why batch? I use my keyboard macro keys to turn my light on or off, and WGET helps me send a request to my server at home. So I needed fast, short, executable, and changeable file to connect to the macro.

Link to comment
Share on other sites

Link to post
Share on other sites

I did not manage using unix time, this is what I was trying to do..

I solved it anyway. (alot of calculations)

Why batch? I use my keyboard macro keys to turn my light on or off, and WGET helps me send a request to my server at home. So I needed fast, short, executable, and changeable file to connect to the macro.

ooh that clever, as in ceiling lights?

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

ooh that clever, as in ceiling lights?

Yea,

I built a friendly "AI" that can recieve voice commands, in a server I had in Amsterdam. my old command sent the server a request with "turn on/off light" and the server did what it needed. (It is so easy in PHP). But I did not renew my server, and the latency anyway was horrible (160ms total process). Now with the new code, Its as fast as my home server can be, and the network. - Pretty fast :)

 

*I did not wire the stuff, I just tapped into the system request's and copied what I needed :P (No API)

 

Old code latency test (and showing off):

Link to comment
Share on other sites

Link to post
Share on other sites

Yea,

I built a friendly "AI" that can recieve voice commands, in a server I had in Amsterdam. my old command sent the server a request with "turn on/off light" and the server did what it needed. (It is so easy in PHP). But I did not renew my server, and the latency anyway was horrible (160ms total process). Now with the new code, Its as fast as my home server can be, and the network. - Pretty fast :)

 

*I did not wire the stuff, I just tapped into the system request's and copied what I needed :P (No API)

 

Old code latency test (and showing off):

very cool, is that a desk lamp or ceiling lights

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

very cool, is that a desk lamp or ceiling lights

just normal ceiling lights (that is what the "yea" reffered to) :)

Link to comment
Share on other sites

Link to post
Share on other sites

just normal ceiling lights (that is what the "yea" reffered to) :)

oh aha, how have you hooked them up to the ceiling lights. im interested :D

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

oh aha, how have you hooked them up to the ceiling lights. im interested :D

"*I did not wire the stuff, I just tapped into the system request's and copied what I needed  :P (No API)"

 

Basicly, when building the house 3 years ago, we contacted a "smart house" electricity company, who wired everything to a central server with something that is like arduino, but simpler (does not need as much features for each component), which was pretty expensive eventually, but now every light, blind, AC, and some sockets have an interface for control through the server.

So I just opened the interface and my console, and turned on and off my light 20 times. Then, I found the pattern of on/off requests, and basicly I send the same request they send through the interface, but through a batch file.

 

Original code:

$milliseconds = round(microtime(true) * 1000);$url = "http://".$this->ip.":".$this->port."/content/state.php?cardId=".$this->id."&time=".$milliseconds."&output=".$state;$GET = file_get_contents($url);

*I had it on a server in amsterdam, because PHP is easier than batch or pretty much anything else :P

 

If you want to do such a thing and you are good with hardware, I recommend arduino. It is easier, and have alot of tutorials on the internet.

Link to comment
Share on other sites

Link to post
Share on other sites

"*I did not wire the stuff, I just tapped into the system request's and copied what I needed  :P (No API)"

 

Basicly, when building the house 3 years ago, we contacted a "smart house" electricity company, who wired everything to a central server with something that is like arduino, but simpler (does not need as much features for each component), which was pretty expensive eventually, but now every light, blind, AC, and some sockets have an interface for control through the server.

So I just opened the interface and my console, and turned on and off my light 20 times. Then, I found the pattern of on/off requests, and basicly I send the same request they send through the interface, but through a batch file.

 

Original code:

$milliseconds = round(microtime(true) * 1000);$url = "http://".$this->ip.":".$this->port."/content/state.php?cardId=".$this->id."&time=".$milliseconds."&output=".$state;$GET = file_get_contents($url);

*I had it on a server in amsterdam, because PHP is easier than batch or pretty much anything else :P

 

If you want to do such a thing and you are good with hardware, I recommend arduino. It is easier, and have alot of tutorials on the internet.

yeah our house is like 30 year old and i dont feel like i want to rip all the plaster out :D i may look at doing it with some lamps tho 

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×