tagged [format]

Formatting a number with leading zeros in PHP

Formatting a number with leading zeros in PHP I have a variable which contains the value `1234567`. I would like it to contain exactly 8 digits, i.e. `01234567`. Is there a PHP function for that?

10 Aug at 04:0

What is the difference between conversion specifiers %i and %d in formatted IO functions (*printf / *scanf)

What is the difference between conversion specifiers %i and %d in formatted IO functions (*printf / *scanf) What is the difference between `%d` and `%i` when used as format specifiers in `printf` and ...

14 Oct at 14:54

DateTime formats used in InvariantCulture

DateTime formats used in InvariantCulture I have to pre-validate in Javascript a string that will be a DateTime in c#. The DateTime parse uses InvariantCulture. Does anyone know the DateTime formats d...

16 Oct at 19:58

How to convert date from yyyyMMdd format to mm-dd-yyyy format

How to convert date from yyyyMMdd format to mm-dd-yyyy format I want to convert a string which contains the date in `yyyyMMdd` format to `mm-dd-yyyy` DateTime format. How do I get it?

15 Oct at 21:4

Date separator issue

Date separator issue I have the following code It always gives me this output : "04.13.2011" instead of "04/13/2011". May I know why I am getting this weird issue?

22 May at 20:42

How to format DateTime to 24 hours time?

How to format DateTime to 24 hours time? I need string from datetime to display time in 24 hours format. The output result have to be: "16:38" Thank you.

16 Sep at 12:31

.NET String.Format() to add commas in thousands place for a number

.NET String.Format() to add commas in thousands place for a number I want to add a comma in the thousands place for a number. Would `String.Format()` be the correct path to take? What format would I u...

2 Dec at 13:9

Going from MM/DD/YYYY to DD-MMM-YYYY in java

Going from MM/DD/YYYY to DD-MMM-YYYY in java Is there a method in Java that I can use to convert `MM/DD/YYYY` to `DD-MMM-YYYY`? For example: `05/01/1999` to `01-MAY-99`

31 Aug at 21:8

How enable auto-format code for Intellij IDEA?

How enable auto-format code for Intellij IDEA? Is it possible in Intellij IDEA after typing ';' or press 'Enter' happened formatting of this string? For instance, to: after: Or only possible option: ?...

26 Jul at 10:51

How should I print types like off_t and size_t?

How should I print types like off_t and size_t? I'm trying to print types like `off_t` and `size_t`. What is the correct placeholder for `printf()` ? Or is there a completely different way to print th...

4 Apr at 10:53

How to format a date with slashes in C#

How to format a date with slashes in C# When i write a date in C# by using then it returns `2010-09-10`, but I need `2010/09/10`. How do I make it output slashes?

10 Sep at 11:27

How can I create basic timestamps or dates? (Python 3.4)

How can I create basic timestamps or dates? (Python 3.4) As a beginner, creating timestamps or formatted dates ended up being a little more of a challenge than I would have expected. What are some bas...

19 Oct at 21:29

String.Format("{0:C2}", -1234) (Currency format) treats negative numbers as positive

String.Format("{0:C2}", -1234) (Currency format) treats negative numbers as positive I am using `String.Format("{0:C2}", -1234)` to format numbers. It always formats the amount to a positive number, w...

Convert milliseconds to human readable time lapse

Convert milliseconds to human readable time lapse I would like to format some commands execution times in a human readable format, for example: Taking into account days, hours, minutes, seconds, ... I...

3 Apr at 13:4

Python int to binary string?

Python int to binary string? Are there any canned Python methods to convert an Integer (or Long) into a binary string in Python? There are a myriad of dec2bin() functions out on Google... But I was ho...

13 Feb at 02:15

Convert a Unix timestamp to time in JavaScript

Convert a Unix timestamp to time in JavaScript I am storing time in a MySQL database as a Unix timestamp and that gets sent to some JavaScript code. How would I get just the time out of it? For exampl...

25 May at 04:43

Why use String.Format?

Why use String.Format? Why would anyone use `String.Format` in C# and VB .NET as opposed to the concatenation operators (`&` in VB, and `+` in C#)? What is the main difference? Why are everyone so int...

12 Jul at 10:42

How to set date format in HTML date input tag?

How to set date format in HTML date input tag? I am wondering whether it is possible to set the date format in the html `` tag... Currently it is yyyy-mm-dd, while I need it in the dd-mm-yyyy format.

29 Oct at 11:8

JSON date from tweeter to C# format

JSON date from tweeter to C# format How to format a JSON date obtained from twitter to a C# DateTime ? Here is the format of the date I receive : Can I do it with JSON.NET ?

19 Feb at 16:43

Reading quicken data files

Reading quicken data files Looking for an open source library, for C++, Java, C# or Python, for reading the data from Quicken files. @Swati: Quicken format is for transfer only and is not kept up to d...

19 Sep at 17:38

Double string.format

Double string.format I have some double values I want to convert to a string with this pattern: Currently I have try this: What should I add in order to see zero in case my number start with zero?

4 Jun at 06:3

Format specifier %02x

Format specifier %02x I have a simple program : I am using `%02x` format specifier to get 2 char output, However, the output I am getting is: while I am expecting it to be :`01010101` .

17 May at 08:55

Integer formatting, padding to a given length

Integer formatting, padding to a given length I need to pad the output of an integer to a given length. For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". Ho...

13 Oct at 04:37

Is CultureInfo.CurrentCulture really necessary in String.Format()?

Is CultureInfo.CurrentCulture really necessary in String.Format()? How do you think is really necessary to provide `IFormatProvider` in method `String.Format(string, object)` ? Is it better to write f...

12 Dec at 18:7

How to pad a binary string with zeros?

How to pad a binary string with zeros? Prints: `1111` I want it to print `00001000` Because the data type is of string and not integer I cannot do something like this:

7 Oct at 02:57