473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how i can use time in condiation

Asghar baig
hi friends i want to create a scripts in which i want to use a function
which works on condiation.that "if time= time" then on click open selected program.
Jan 12 '07 #1
4 1420
acoder
16,027 Expert Mod 8TB
hi friends i want to create a scripts in which i want to use a function
which works on condiation.that "if time= time" then on click open selected program.
Use the Date function.
Expand|Select|Wrap|Line Numbers
  1. var today=new Date();
  2. var h=today.getHours();
  3. var m=today.getMinutes();
  4. var s=today.getSeconds();
Use the h, m and s values to compare with the time that you want.
Jan 12 '07 #2
Expand|Select|Wrap|Line Numbers
  1. var today=new Date();
  2. var h=today.getHours();
  3. var m=today.getMinutes();
  4. var s=today.getSeconds();
  5. if(h=02)&&(m=30){
  6. window.open("http://www.thescripts.com");
  7. }
  8. alert("u can open it only at 02:30 o clock");
  9.  
what i have to for this
Jan 13 '07 #3
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. var today=new Date();
  2. var h=today.getHours();
  3. var m=today.getMinutes();
  4. var s=today.getSeconds();
  5. if(h=02)&&(m=30){
  6. window.open("http://www.thescripts.com");
  7. }
  8. alert("u can open it only at 02:30 o clock");
  9.  
what i have to for this
Realise that h = 02 is different from h == 02.
Jan 13 '07 #4
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. var today=new Date();
  2. var h=today.getHours();
  3. var m=today.getMinutes();
  4. var s=today.getSeconds();
  5. if(h=02)&&(m=30){
  6. window.open("http://www.thescripts.com");
  7. }
  8. alert("u can open it only at 02:30 o clock");
  9.  
what i have to for this
In your code above, you are setting instead of comparing h and m. Also, h, m and s only return numbers without starting zeros. So you should be comparing with 2 only, not 02.
Jan 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Bart Nessux | last post by:
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting...
5
by: David Stockwell | last post by:
I'm sure this has been asked before, but I wasn't able to find it. First off I know u can't change a tuple but if I wanted to increment a time tuple by one day what is the standard method to do...
6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
4
by: Andrew Poulos | last post by:
How do I convert a length of time, measured in seconds, into a "point in time" type time interval or what's represented as: time (second,10,2) The format is: PS]] where: y: The number of...
8
by: peterbe | last post by:
What's the difference between time.clock() and time.time() (and please don't say clock() is the CPU clock and time() is the actual time because that doesn't help me at all :) I'm trying to...
3
by: Szabolcs Nagy | last post by:
I have to measure the time of a while loop, but with time.clock i always get 0.0s, although python manual sais: "this is the function to use for benchmarking Python or timing algorithms" So i...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
5
by: Erich Schreiber | last post by:
In the Python Library Reference the explanation of the time.sleep() function reads amongst others: > The actual suspension time may be less than that requested because > any caught signal will...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.