Results 1 to 11 of 11

Thread: VBScript - format time

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    VBScript - format time

    is there a way to format the time so that it does not show seconds... i am using the formatdatetime() function... but it displays seconds in it... you can't customize the format like you can with the VB format() function

  2. #2
    Lively Member
    Join Date
    Sep 2002
    Location
    chile
    Posts
    74
    i found this article which i think will be really helpfull

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=48

    good luck

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by niske
    i found this article which i think will be really helpfull

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=48

    good luck
    that has nothing to do with formatting the date/time though

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Code:
    dim todaysDate
    todaysDate = now()
    Response.write FormatDateTime(todaysDate,4)

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by kleinma
    that has nothing to do with formatting the date/time though
    ROFL.

  6. #6
    Lively Member
    Join Date
    Sep 2002
    Location
    chile
    Posts
    74
    sorry, guess i'm not really awake yet

  7. #7

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by mendhak
    Code:
    dim todaysDate
    todaysDate = now()
    Response.write FormatDateTime(todaysDate,4)
    i want to preserve the AM PM 12 hour clock though... formatting it using 4 gives you military time..

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by kleinma
    i want to preserve the AM PM 12 hour clock though... formatting it using 4 gives you military time... Do it you stupid frog! I'll give you a big fat joint if you do it!!
    Picky, picky picky.

    Code:
    dim todaysDate
    todaysDate = now()
    Response.write FormatDateTime(todaysDate,4)
    Response.Write "<BR>"
    
    dim abc, def, ghi
    abc = cstr(FormatDateTime(todaysDate,4))
    
    def = mid(abc,1,instr(1,abc,":")-1)
    
    ghi = cint(def)
    if ghi > 12 then
    ghi = ghi - 12
    abc = replace(abc,def,cstr(ghi)) & " PM"
    else
    abc = abc & " AM"
    
    end if
    
    Response.Write "<BR><BR>" & abc
    %>

  9. #9
    Lively Member
    Join Date
    Oct 2002
    Posts
    88
    how to show date n time in asp form that it will auto update the time every second without refreshing the form?
    can show code?

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by hongge
    how to show date n time in asp form that it will auto update the time every second without refreshing the form?
    can show code?
    You could use javascript for that.

  11. #11
    New Member
    Join Date
    Nov 2016
    Posts
    1

    Re: VBScript - format time

    I realize I'm probably beating a dead horse here, but..

    Code:
       Dim crntTime
       crntTime = Left(Time,5) & Right(Time,3)
    Which will output hh:mm tt

Posting Permissions

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



Click Here to Expand Forum to Full Width