Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. var today = new Date(); is giving me this error: Microsoft JScript runtime error: Object expected

var today = new Date(); is giving me this error: Microsoft JScript runtime error: Object expected

Scheduled Pinned Locked Moved Web Development
helpjavascriptquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S Rajput
    wrote on last edited by
    #1

    I dont know why this statement is giving me error . I have written this in a Javascript file that is attached to my project. I am trying to declare a variable containing todays date. Can Anyone help please?

    C L A 3 Replies Last reply
    0
    • S S Rajput

      I dont know why this statement is giving me error . I have written this in a Javascript file that is attached to my project. I am trying to declare a variable containing todays date. Can Anyone help please?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      are you certain this line has the error ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      S 1 Reply Last reply
      0
      • C Christian Graus

        are you certain this line has the error ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        S Offline
        S Offline
        S Rajput
        wrote on last edited by
        #3

        Absolutely, I am using Visual studio 2008. I tried following code in studio 2005 now but i am getting same error. Not sure why it is occuring? Really strange.. Is there any other way to get todays date in some variable? function Test() { var today = new Date(); alert(today); } <asp:Button ID="Button1" runat="server" OnClientClick="Test();" Text="Button" /><br />

        1 Reply Last reply
        0
        • S S Rajput

          I dont know why this statement is giving me error . I have written this in a Javascript file that is attached to my project. I am trying to declare a variable containing todays date. Can Anyone help please?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I used the below code and it worked fine for me

          <script type="text/javascript">
          var today = new Date();
          alert(today);
          </script>

          Regards Aman Bhullar www.arlivesupport.com[^]

          S 1 Reply Last reply
          0
          • L Lost User

            I used the below code and it worked fine for me

            <script type="text/javascript">
            var today = new Date();
            alert(today);
            </script>

            Regards Aman Bhullar www.arlivesupport.com[^]

            S Offline
            S Offline
            S Rajput
            wrote on last edited by
            #5

            It should work because it is a correct code. But what can be the reason for it to be failing? Everytime i try to declare any Date variable it gives me : Microsoft JScript runtime error: Object expected I have tried to reboot my pc still it doesnt work.. Is my Jscript engine corrupted or something?

            1 Reply Last reply
            0
            • S S Rajput

              I dont know why this statement is giving me error . I have written this in a Javascript file that is attached to my project. I am trying to declare a variable containing todays date. Can Anyone help please?

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              I think your browser got whacked somehow. Reinstalling the browser will help you. Date is a prototype should be declared within the library of browser. :doh: :doh: It is working for all of us. Sorry cant help you. :sigh: :sigh:

              Abhishek Sur


              My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

              **Don't forget to click "Good Answer" if you like to.

              S 1 Reply Last reply
              0
              • A Abhishek Sur

                I think your browser got whacked somehow. Reinstalling the browser will help you. Date is a prototype should be declared within the library of browser. :doh: :doh: It is working for all of us. Sorry cant help you. :sigh: :sigh:

                Abhishek Sur


                My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                **Don't forget to click "Good Answer" if you like to.

                S Offline
                S Offline
                S Rajput
                wrote on last edited by
                #7

                Now..the following statement is giving me error: Sys is undefined. var wRequest = new Sys.Net.WebRequest(); I have no clue whats been hapening, i have reinstalled latest ajax toolkit but it is still occuring.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups