ASP time conversion numbers, string methods

Source: Internet
Author: User
Tags date end string string format string methods

ASP I want to take time like 2009-8-4 16:03:04 in the number, but with the CStr function or other conversion is 2009841634, how can I make it into "200984160304"? It also shows two digits when the number is less than 10 in time.

<%

Str=now

Str=replace (str, "", "")

Str=replace (str, "-", "")

Str=replace (str, ":", "")

Str=replace (str, "a.m.", "")

Str=replace (str, "PM", "")

Response.Write Str

%>

'***************************************************

' Function name: Getyyyymmddhhiiss

' Function: Converts a given date and time data to a Yyyymmddhhiiss string format

' Parameters: D-Date data, T-time data

' return value: converted String

'***************************************************

Function Getyyyymmddhhiiss (d,t)

Yyyy=year (d)

Mm=month (d)

Dd=day (d)

Hh=hour (t)

Ii=minute (t)

Ss=second (t)

If Len (YYYY) =2 Then

yyyy= "& YYYY"

End If

If Len (MM) =1 Then

mm= "0" & MM

End If

If Len (DD) =1 Then

Dd= "0" & DD

End If

If Len (HH) =1 Then

Hh= "0" & HH

End If

If Len (II) =1 Then

Ii= "0" & II

End If

If Len (SS) =1 Then

ss= "0" & SS

End If

Getyyyymmddhhiiss=yyyy & MM & DD & HH & II & SS

End Function



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.