www.webdeveloper.com
Results 1 to 8 of 8

Thread: ASP % equivalent and Date() object

  1. #1
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276

    ASP % equivalent and Date() object

    Hi everyone, does anyone know the VBScript equivalent of client-side JavaScript's % which gives the remander when one number is divided by another, so for example 5%3 would equal 2.

    Also, I am using ASP's built in Date() object but since the server is a few hours behind GMT it sometimes gets it wrong, so is there a way to correct for this? Is there a way to do this for the time as well?
    Even better, is it possible to detect what time zone a user is in and how far ahead or behind they are? This would mean that the times and dates are always correct for everyone.
    Every fight is a food fight when you’re a cannibal.

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    For modulus, VBScript uses the mod operator.
    Code:
    dim x
    x = 10 mod 3 'should return 1.
    As for the date/time issue, take a look at this article. http://www.webwizguide.info/asp/faq/...e_settings.asp

    Regards,
    Andrew Buntine.

  3. #3
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    Thanks for the mod operator, but the dates and times thing isn't quite what I need:

    Please note that this will only change the format the dates, times, and currencies are shown in and will not move dates and times to another time zone. eg. mm/dd/yyyy to dd/mm/yyyy.
    I have already sorted out the dd/mm/yyyy thing, I just need to change the time zone to GMT (or if possible, change the time zone to match the time zone that the user is in).
    Every fight is a food fight when you’re a cannibal.

  4. #4
    Join Date
    Sep 2003
    Posts
    123
    You'd have to find out what the server time offset is and then you can use the dateadd function

    Small VB example:
    Code:
    MsgBox DateAdd("h", 1, Now)
    As far as finding out the time of the browser, you would have to use javascript (or jscript, javascript's bastard brother).

  5. #5
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    I could find the time on the user's clock very easily with JavaScript, it's just that that would involve a refresh of the page so that the script could get the info transferred to it.
    Then I would have to start using Session variables (which apparently are a bad thing) to keep that information available for the script to use.
    It's a real shame that there is no server-side way to obtain that stuff.

    Ah well, back to work on the script for me. Thanks guys.
    Every fight is a food fight when you’re a cannibal.

  6. #6
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    We should devise some wicked technology thats allows client-server communication easily.

  7. #7
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    We could call it LavaScript.
    Every fight is a food fight when you’re a cannibal.

  8. #8
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    Or BuntineIsSoCoolIWishIWasJustLikeHim++

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles