Hi, i'm newbie in C#, Consider following function in java: - int getMilliseconds(){ Date dt=new Date(); return(dt.getTime()); }
pls help me to convert this in C#
7 34505
reply Fast, I'm waiting for the reply
DateTime.Now.Mi llisecond;
Millisecond is a property of the datetime class.
It wil return the current state of the millisecond part of the time.
Is tat what you are looking for?
No, not in that way, -
<html>
-
<body>
-
<button onclick="var myDate = new Date(); alert(myDate.getTime());">
-
get time
-
</button>
-
</body>
-
</html>
-
i just want to convert the line
"var myDate = new Date(); alert(myDate.ge tTime());" into C#
No, not in that way, -
<html>
-
<body>
-
<button onclick="var myDate = new Date(); alert(myDate.getTime());">
-
get time
-
</button>
-
</body>
-
</html>
-
i just want to convert the line
"var myDate = new Date(); alert(myDate.ge tTime());" into C#
If you want the current date and time, use -
DateTime myDate = DateTime.Now;
-
Now myDate has the current date and time. That object has all the members and methods you need to convert that time to any format or break out any part of it you need.
If this is a Windows Forms application, the next part would be: -
MessageBox.Show(myDate.ToShortTimeString());
-
If this is an ASP.NET web app, I don't think that there is any way to create a client-side pop up from C#.
If you want the current date and time, use -
DateTime myDate = DateTime.Now;
-
Now myDate has the current date and time. That object has all the members and methods you need to convert that time to any format or break out any part of it you need.
If this is a Windows Forms application, the next part would be: -
MessageBox.Show(myDate.ToShortTimeString());
-
If this is an ASP.NET web app, I don't think that there is any way to create a client-side pop up from C#.
Gr8, thanx for relplying
Just to inform you. Your code was javascript and not java !
if you are using a system, where the current time is not in UTC, then this will not work. javascript getTime gets the diff with UTC.
# private Int64 GetTime()
# {
# Int64 retval=0;
# DateTime st=DateTime(197 0,1,1);
# TimeSpan t= (DateTime.Now.T oUniversalTime( )-st);
# retval= (Int64)(t.Total Milliseconds+0. 5)
# return retval;
# }
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Phil Powell |
last post by:
I am forced to have to compare the value of some PHP timestamp with a
Java-based java.util.Date.getTime() timestamp. Let me show you how
they look:
The Java time is returned to the PHP class method as mixed but could
be converted to float I would think, but how would I ensure that they
|
by: Dave Rahardja |
last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at
work. He is a proponent of the Template Method pattern, i.e.:
class foo
{
public:
void bar() { do_bar(); }
protected:
virtual void do_bar() {}
};
|
by: Chris |
last post by:
Hi
I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have the same class/static method definition statictly linked to my EXE and when I call InvokeMember(...), even though I got the Type from the new AppDomain,...
|
by: Shane |
last post by:
I have this peice of Javascript, im trying to convert in to VB.net. Everything work ok. I almost get the some value, but the last 5 numbers are all Zeros on my VB out put. the Java version has numbers there and makes the out a little different. I want to know if there is a better why in VB i can do this
I am taking the difference of two dates...
|
by: Xiangliang Meng |
last post by:
Hi, all
class Clock
{
Clock() { Time_m = 0;}
void setTime(unsigned int time = 0)
{
Time_m = time;
}
unsigned int getTime() const
| |
by: daniel.w.gelder |
last post by:
I wrote a template class that takes a function prototype and lets you
store and call a C-level function, like this:
inline string SampleFunction(int, bool) {..}
functor<string (int, bool)> myFunctor = SampleFunction;
string result = myFunctor(7, true);
Works great thanks to the help from this group. Here's the guts so far
for two-arity:
|
by: Russ Chinoy |
last post by:
Has anyone ever noticed that getTime() returns the same value for both today
(5/31/2005) and tomorrow (6/1/2005)?
You can quickly see it with this page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script>
|
by: Shane Saunders |
last post by:
I trying to make a sub that works like Javascripts .getTime method. It work
ok, but it does not should the time in it. The last numbers should be the
time, but they are all zeros. Can anyone help me on this. here is the code i
used. From reading i also seen that the getTime time starts on 01/01/1970
12am. I need to have this in Millsecond.
...
|
by: anj2k5 |
last post by:
Hello ,
I want to create a function in C#.net which is equivalent to gettime(milliseconds since midnight 1st January, 1970 ) function in javascript.
Actually i need to calculate unique value in c#.net as given in following javascript
//javascript
var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
I used following code...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |