Results 1 to 5 of 5

Thread: c# function equivalent to gettime function in javascript

  1. #1
    Join Date
    Nov 2009
    Posts
    35

    c# function equivalent to gettime function in javascript

    Hello to all,
    I am working on one live project where I am using javascript. In my project I want to create c# function which equivalent to gettime() function in javascript. I tried various method, but none of them worked out. Can anyone tell me how to create c# function equivalent to gettime function in javascript? Please help me.
    Thank you.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: c# function equivalent to gettime function in javascript

    Hey you have to use following code to do this.
    Code:
    var uniques = ds.getTime() + '' + Maths.floor(1000 * Maths.random());
    First you have to use above javascript and then you ave to use following code.
    Code:
    string vala2;
    Random rana=new Random();
    int number=rana.Next(0,1250);
    vala2 = (inta) Matha.Floor(number);

  3. #3
    Join Date
    Oct 2005
    Posts
    2,394

    Re: c# function equivalent to gettime function in javascript

    As per my information NET file has the DateTime object and that's why you are getting such type of problem. In this case you have to use DateTime to get current Date and Time. It is very simple to use and implement.
    You also have to use the ToString() method to return your specific format in your code.

  4. #4
    Join Date
    May 2008
    Posts
    2,393

    Re: c# function equivalent to gettime function in javascript

    As per my information you have to provide particular format to tostring() to get rid out of this problem. This format must be equivalent to
    gettime() in javascript. You can do this in following ways.
    Code:
    string valas2;
    Random ransa=new Random();
    int number=ransa.Next(0,1250);
    valas2 = (inta) Maths.Floor(number);

  5. #5
    Join Date
    Feb 2008
    Posts
    1,856

    Re: c# function equivalent to gettime function in javascript

    I have use one function in the following code which is equivalent to gettime function in javascript. Just try to understand it. In the following code I have use Int64 GetTime() to get proper result. Just try to understand it.
    Code:
    private Int64 GetTimes() {
        Int64 retvals=0;
       DateTime sts=DateTimes(1970,1,1);
       TimeSpan tss= (DateTimes.Now-sts);
      retvals= (Int64)(ts.TotalMilliseconds+0.5)
       return retvals;
     }

Similar Threads

  1. c++ equivalent function to the c-function 'sprintf
    By Dilbert in forum Software Development
    Replies: 6
    Last Post: 13-12-2011, 03:03 PM
  2. C# Equivalent Of Javascript's Location.replace() Function?
    By ASHER in forum Software Development
    Replies: 6
    Last Post: 16-05-2010, 01:20 AM
  3. Javascript isNull function
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 01:51 PM
  4. How to implement the INITCAP equivalent function in SQL Server
    By TechPredator in forum Software Development
    Replies: 3
    Last Post: 06-08-2009, 03:33 PM
  5. JavaScript function help
    By suseman in forum Software Development
    Replies: 3
    Last Post: 26-05-2009, 05:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •