| |

VerySource

 Forgot password?
 Register
Search
View: 718|Reply: 6

Ask: how to format ‘11’ as ‘0101’

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-21 18:00:02
| Show all posts |Read mode
Ask: how to format ‘11’ into ‘0101’, that is, format the string into MMDD format
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-6-28 17:30:01
| Show all posts
Convert.ToDateTime(1999121)
Reply

Use magic Report

0

Threads

16

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-6-28 18:30:01
| Show all posts
DateTime a = new DateTime(2016,7,9,11,9,1)
Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, and second.

Your string needs to be split
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-28 21:00:01
| Show all posts
How to format ‘11’ into ‘0101’, that is, format the string into MMDD format
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-6-29 00:00:02
| Show all posts
Convert.ToDateTime("11-2").ToString();
This format can be converted to MMDD
If you want to use pure 11 to convert to 0101, you may need to write a method yourself
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-29 10:15:01
| Show all posts
Can't the string.Format method convert 11 to 0101? ?
Reply

Use magic Report

0

Threads

16

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-6-30 09:15:01
| Show all posts
People know that "11" is "January 1st", and the two-digit number is fine, but what if it is "111"? Is it January 11th or November 1st?
It will be confusing, so first split to specify the month and day.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list