> For the complete documentation index, see [llms.txt](https://docs.dot-net.uz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dot-net.uz/c-.net/desktop/wpf-windows-presentation-foundation-1/qoshimcha-malumotlar/son-va-vaqtni-formatlash.md).

# Son va Vaqtni Formatlash

Siz ko’p xollarda sonlarni quidagi ko’rinishlarda ko’rgansiz:

* RUSSIA 123 345 456 122.89
* USA 123,145,456,122.89
* Germany 123.145.456.122,89

Bunday ko’rinishlar ko’p davlatlarda farqli bo’ladi.  Siz agar dasturingizda bularni davlatga mos xolda chiqarishni xoxlashingiz mumkin. Va vaqtlarni ham shunga mos qilsangiz bo’ladi.

* RUSSIA           14.02.2020 23:30
* USA                  2/14/2020 11:30 PM
* Germany         14.02.2020 23:30

Bu xolda formatlash aslida ko’p ish bo’lishi mumkin, ammo .NET bizga tayyor classlarni taklif qiladi. Bunda bizga *CultureInfo* classi kerak bo’ladi.

Avvalo **System.Globalization** Kutubxonasini chaqirib qo’yishimiz kerak bo’ladi.1- WPF da ko’rinishni kiritib olishimiz kerak.

```aspnet
<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="400">
    <StackPanel TextElement.FontSize="20" Margin="20">
        <DockPanel>
            <TextBlock>Sonlar : </TextBlock>
            <TextBlock x:Name="sonlar" Margin="50 0 0 0" Text="123145456122.89"/>
        </DockPanel>
        <DockPanel Margin="0 20 0 0">
            <TextBlock>Sonlar :</TextBlock>
            <TextBlock x:Name="vaqt" Margin="50 0 0 0" Text="2-14-2020 11:28"/>
        </DockPanel>
        <Button Margin="0 20 0 0" Tag="en" Content="USA" Click="Button_Click"/>
        <Button Margin="0 20 0 0" Tag="ru" Content="Russia" Click="Button_Click"/>
        <Button Margin="0 20 0 0" Tag="de" Content="Germany" Click="Button_Click"/>
    </StackPanel>
</Window>

```

Endi esa Tugma bosilish xodisasiga formatlarni o’zgarishini qo’llab qo’yamiz.

```csharp
using System;
using System.Globalization;
using System.Threading;
using System.Windows;
using System.Windows.Controls;

namespace WpfApp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            double son = 123145456122.89;
            Thread.CurrentThread.CurrentCulture = new CultureInfo((sender as Button).Tag.ToString());
            sonlar.Text = son.ToString("n2");
            vaqt.Text = DateTime.Now.ToString();
        }
    }
}

```

&#x20;Natijani ko’rishingiz mumkin:                                      &#x20;

![default holatida](/files/-MYj1V86arRkxVBJvsvF)

![USA tugmachasini bosilganda](/files/-MYj1fREt23UdA1hHmbx)

Ko’rib turganingizdek sonlar formati o’zgardi. Ya’ni davlatda ishlatiladigan formatga qarab o’zgaradi. Odatda bunday usul dasturni o’rnatayotgan vaqtda sistemada tanlangan davlatga qarab son va vaqtni formatlash amalga oshiriladi


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.dot-net.uz/c-.net/desktop/wpf-windows-presentation-foundation-1/qoshimcha-malumotlar/son-va-vaqtni-formatlash.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
