Hello ,
I want to create a function in C#.net which is equivalent to gettime(millise conds 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 in c# - string val2;
-
Random ran=new Random();
-
int number=ran.Next(0,1000);
-
val2 = (int) Math.Floor(number);
-
But I dnt which function is used for gettime.
Pls.help me..
Anjana
12 14720 Plater 7,872
Recognized Expert Expert
.NET has the DateTime object.
Use DateTime.Now to get the current Date and Time.
But it gives time in different form,I want to actual format of gettime()
But it gives time in different form,I want to actual format of gettime()
use the ToString() method to return your specific format.
cheers
But i dnt knw which format i have to provide in tostring() which is equivalent to
gettime() in javascript.
Plater 7,872
Recognized Expert Expert
But i dnt knw which format i have to provide in tostring() which is equivalent to
gettime() in javascript.
Well how about LOOKING at it, and deciding.
OR look up to see what format gettime() in javascript returns as and then you can force the DateTime object to output in that format.
Time to do some of your own leg work there.
gettime function of javascript return milliseconds since midnight 1st January, 1970.
Would you tell me for this which format i should used?
Plater 7,872
Recognized Expert Expert
gettime function of javascript return milliseconds since midnight 1st January, 1970.
Would you tell me for this which format i should used?
Well to ensure it: -
private Int64 GetTime()
-
{
-
Int64 retval=0;
-
DateTime st=DateTime(1970,1,1);
-
TimeSpan t= (DateTime.Now-st);
-
retval= (Int64)(t.TotalMilliseconds+0.5)
-
return retval;
-
}
-
There, did the whole thing for you.
Thanks for this.I'll apply this
Thanks for writing up this description. I'm not sure that the original poster had a full appreciation for your comments and support but I do - it saved me a great amount of time. Problem solved! @Plater Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bartosz Wegrzyn |
last post by:
Any ideas why this function is not working.
I am running it locally on my private network.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Javascript Webcam for Internet Explorer</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
|
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 and making them in to a long intger. here is the code for both and the out put
VB.net Code
Dim...
|
by: Steven |
last post by:
Hello,
How to call a C# function (eg., main()) from a Javascript funtion (eg.,
ref()).
-- Steven
|
by: Steve |
last post by:
Is there equivalent of sscanf function in .NET?
I need to parse string with network MAC address (For example like
11-22-33-44-55-66) and extract each segment into array of bytes.
Can anyone advise what method/class I can use for that?
I've figured out how to parse IP address: IPAddress.Parse(hostName), but
can't find easy way to parse MAC address.
|
by: ljlolel |
last post by:
I'm posting this again because I did not explain myself well the first
time, so the problem was not being addressed. I made the following
page ( http://perla.princeton.edu/counselors/organization.php ) solely
for the purpose of showing a bug. It is not production code, it is a
test, made for testing, so style really doesn't matter.
This page illustrates that, for some reason, clicking on the submit
button has a different effect on the...
| |
by: Boricua |
last post by:
I'm using ASP.NET 2.0
I got an imagebutton at the end of my form as a submit button. When
the user clicks it the button becomes disabled and continues with the
postback.
This is what I got, ib is the imagebutton.
Dim sbValid As New StringBuilder()
sbValid.Append("if(typeof(Page_ClientValidate)=='function'){ ")
sbValid.Append("if (Page_ClientValidate() == false) { return
false; }} ")
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: Adam Kubica |
last post by:
Hellou.
Anybody know about code that work equivalent to gzinflate()
function used in PHP?
I search via google but I don't found anything sensible :-(
|
by: Waldy |
last post by:
Hi there,
I have a customer requirement to provide a web application
without JavaScript. A function is being written to the HTML output on some
pages. The function is called __doPostBack. How do I get rid of it. There
is no call to the function in the rest of the page, so why is it being
written to the client?
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |