Questions tagged [date-conversion]

Conversion of dates from one calendar or notation to another, for example, converting Julian calendar February 29, 1700 to Gregorian calendar March 11, 1700, or "March 11, 1700" to "1700-03-11".

688 questions
380
votes
18 answers

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date('Y-m-d H:i:s',…
Tom
  • 30,090
  • 27
  • 90
  • 124
133
votes
10 answers

How to get the integer value of day of week

How do I get the day of a week in integer format? I know ToString will return only a string. DateTime ClockInfoFromSystem = DateTime.Now; int day1; string day2; day1= ClockInfoFromSystem.DayOfWeek.ToString(); /// it is not working day2=…
akshaykumar6
  • 2,147
  • 4
  • 18
  • 31
131
votes
7 answers

Go time.Now().UnixNano() convert to milliseconds?

How can I get Unix time in Go in milliseconds? I have the following function: func makeTimestamp() int64 { return time.Now().UnixNano() % 1e6 / 1e3 } I need less precision and only want milliseconds.
mconlin
  • 8,169
  • 5
  • 31
  • 37
98
votes
9 answers

How to convert a string Date to long millseconds

I have a date inside a string, something like "12-December-2012". How can I convert this into milliseconds (long)?
Dawood Ahmed
  • 1,734
  • 4
  • 23
  • 36
86
votes
6 answers

How to remove the time portion of a datetime value (SQL Server)?

Here's what I use: SELECT CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME) I'm thinking there may be a better and more elegant way. Requirements: It has to be as fast as possible (the less casting, the better). The final result has to be a…
Nathan Bedford
  • 8,924
  • 5
  • 35
  • 29
81
votes
7 answers

Converting unix time into date-time via excel

Trying to convert 1504865618099.00 Unix time into a readable date time. I tried this: =(UNIX + ("1/1/1970"-"1/1/1900"+1)*86400) / 86400 But it's not working.
JohnSmith
  • 1,078
  • 1
  • 10
  • 21
64
votes
7 answers

How convert Gregorian date to Persian date?

I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents: string GregorianDate = "Thursday, October 24, 2013"; Now i want to have: string PersianDate = پنج‌شنبه 2 آبان 1392 ; or string…
JAC
  • 950
  • 1
  • 7
  • 11
32
votes
6 answers

How to convert LocalDateTime to OffsetDateTime?

How to convert LocalDateTime to OffsetDateTime? private OffsetDateTime getEntryDate(Payment payment) { return Optional.ofNullable(payment) .map(Payment::getEntryDate) .map(SHOULD RETURN OffsetDateTime) …
Melad Basilius
  • 3,847
  • 10
  • 44
  • 81
28
votes
10 answers

Convert PHP date into javascript date format

I have a PHP script that outputs an array of data. This is then transformed into JSON using the json_encode() function. My issue is I have a date within my array and it's not in the correct JavaScript format. How can I convert this within PHP so…
LeeTee
  • 6,401
  • 16
  • 79
  • 139
27
votes
1 answer

Convert "unknown format" strings to datetime objects?

This is probably a very basic question but after reading documentation I still can't figure out how to do it... I have two strings in Python that contain dates of unknown format. I don't know what formats they are in, except I know that both are…
I Z
  • 5,719
  • 19
  • 53
  • 100
27
votes
6 answers

How can I convert a date in Epoch to "Y-m-d H:i:s" in Javascript?

How can I convert following date in epoch: 1293683278 to following readable date: 2010-06-23 09:57:58 using Javascript? Thanks!
James Cazzetta
  • 3,122
  • 6
  • 32
  • 54
23
votes
2 answers

Convert this string to timestamp PHP

I have this string: "13/10 15:00" and I would like to convert it to timestamp but when I do this: $timestamp = strtotime("13/10 15:00"); It returns an empty value.
user2876368
  • 667
  • 2
  • 6
  • 7
23
votes
8 answers

Convert String Date to String date different format

I am new to Java. Postgres db contain date format is yyyy-MM-dd. I need to convert to dd-MM-yyyy. I have tried this, but wrong result is display public static void main(String[] args) throws ParseException { String strDate = "2013-02-21"; …
22
votes
5 answers

Converting Gregorian date to Hijri date

How do you convert Gregorian dates to Islamic Hijri dates using JavaScript?
FuNk
  • 223
  • 1
  • 2
  • 6
18
votes
2 answers

VBA - convert to date

I have one more time a problem: I want to convert from Strings to dates in VBA The Strings look like: YYYY-DD-MM The date should be like: DD.MM.YYYY I know, normally you do this with the method cdate(), but it doesn't work here. I think it's because…
InformatikBabo
  • 510
  • 2
  • 8
  • 19
1
2 3
45 46