*hi,
how convert 13 digits of timestamp like 1238536800000 into small number with 6 digits It is easy to deal with it.
THANKS *

7 commentaires

Walter Roberson
Walter Roberson le 5 Juil 2015
Please give us a sample timestamp and the exact time that it represents. Are the timestamps relative or absolute times? Are they possibly something like microseconds since a fixed time (as seen in MS Windows sometimes) ?
nada ali
nada ali le 5 Juil 2015
like : datestr(730851) ans = 31-Dec-2000 currently, I need only date thanks
Azzi Abdelmalek
Azzi Abdelmalek le 5 Juil 2015
You have the date. What is the problem?
Hi Nada,
If you have MATLAB 2014b or above, you can also use datetime to accomplish what you need. For example:
>> myDate = datetime(730851,'ConvertFrom','datenum')
myDate =
31-Dec-2000 00:00:00
Then you can conveniently extract various datetime components such as:
>> myYear = year(myDate)
myYear =
2000
For more details please refer to documentation: Components of Dates and Time
nada ali
nada ali le 7 Juil 2015
No I have no matlab 14, Aziz i have no date that is only example what I need is how convert 1238536800000 into date thanks
Stephen23
Stephen23 le 7 Juil 2015
Modifié(e) : Stephen23 le 7 Juil 2015
@nada ali: what epoch and increment does that timestamp have? Without knowing what time system or encoding this timestamp uses, your question is impossible to answer.
nada ali
nada ali le 7 Juil 2015
Modifié(e) : nada ali le 7 Juil 2015
thanks I just found the dataset with the following format including timestamp
*userID artistID tagID timestamp
2 52 13 1238536800000
2 52 15 1238536800000
2 52 18 1238536800000
2 52 21 1238536800000
2 52 41 1238536800000*

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 8 Juil 2015

0 votes

Divide the 13 digit timestamp by 1000 to get seconds. Divide by 24 * 60 * 60 to get days. Add datenum('1970-1-1'). The result will be a MATLAB date number.
This task would have been easier if you had identified the source of the data; I tracked it down by searching on the heading you provided and showed that it was an extract of last.fm data. After that it was a matter of researching to find out what timestamp format that last.fm used. When that was unsuccessful I took a sample timestamp from the last.fm site and googled it and was fortunate to find a discussion about Drupal in which someone was asking about proper conversion of the timestamp, and that gave me a target date to reverse-engineer from. The rest was based upon my historical knowledge of Unix timestamps starting at January 1 1970.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 5 Juil 2015
Modifié(e) : Azzi Abdelmalek le 5 Juil 2015
use
format short
or
s=1238536800000
fprintf('%6.6g\n',s)

Catégories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by